Wolfgang Maier added the comment:
Ok, I finally managed to get the test suite right for this, so here is the
patch diff for everything.
I made a few final changes to the module itself (mostly to please the test
suite), so I'll edited the complete code as well.
--
keywords: +
Changes by Wolfgang Maier :
Added file: http://bugs.python.org/file33959/statistics.py
___
Python tracker
<http://bugs.python.org/issue20499>
___
___
Python-bugs-list m
Wolfgang Maier added the comment:
In principle, your approach using itertools.groupby, the existing _sum, your
decimalsum, and my _ExactRatio class could be combined.
You could call decimalsum for Decimal and subclasses, the current _sum for
everything else.
_sum would return an _ExactRatio
New submission from Wolfgang Maier:
Can this still be fixed in 3.4 ??
I came across this bug in the statistics module today:
>>> import statistics
>>> data = [Decimal('1e4')]
>>> statistics.mean(data)
Traceback (most recent call last):
File "",
Wolfgang Maier added the comment:
#if type(den) != int:
#print (d, sign, digits, exp, num, den)
was inserted by me of course for debugging this. Forgot to take it out again.
--
___
Python tracker
<http://bugs.python.org/issue20
Changes by Wolfgang Maier :
--
nosy: +ncoghlan
___
Python tracker
<http://bugs.python.org/issue20561>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
Steven,
I think
if exp >= 0:
return int(x), 1
would have been a better patch, but yours is certainly working, just slower I
guess.
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issu
Wolfgang Maier added the comment:
I worked out a slightly speedier version of decimal_to_ratio today (Stefan:
that's when I duplicated your bug report):
from decimal import Context
def _decimal_to_ratio (x):
_, digits, exp = x.as_tuple()
if exp in _ExactRatio.decimal_infinite:
Wolfgang Maier added the comment:
oops,
> if exp in _ExactRatio.decimal_infinite: # INF, NAN, sNAN
should read
if exp in ('F', 'n', 'N'): # INF, NAN, sNAN
of course. What I pasted comes from a micro-optimization I tried, bu
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue27761>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
Issue23016 fixed the "AttributeError: 'NoneType' object has no attribute
'write'" problem when sys.stderr is None.
With that it's now possible and good practice to set sys.stderr = None when
closing it, just as Antoine sug
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue10379>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
Ping. This still isn't fixed several years later, i.e., the documentation still
describes the POSIX, but not the Windows behavior.
See also issue20927, which reports this as a bug.
--
nosy: +wolma
versions: +Python 3.5, Python 3.6, Python 3.7 -P
Wolfgang Maier added the comment:
Before I forget again what I've gathered yesterday about this issue, here's a
summary of the problem:
When the the first element of args or the executable argument of
subprocess.Popen does not specify an absolute path, the way the executable gets
Wolfgang Maier added the comment:
Hi Julius,
I guess it's a question of control and responsibilities.
If you write a program that may issue warnings under some conditions, that
program may, for example, be used with stderr redirected to a file. Now it is
possible that file gets removed
Wolfgang Maier added the comment:
Ah, I just found Issue607668, which discusses the changeset 2e7fe55c0e11 that
introduced IOError suppression. The actual use case at the time was different
and I have no idea whether it would still be a problem today
Wolfgang Maier added the comment:
Ah, that's kind of confusing at first!
the 'self' in the method calls (like on line 796) refers to the ConfigParser
instance and will be bound to the parser parameter. The first parameter, the
'self' in the interpolation method defin
Wolfgang Maier added the comment:
> Ah. Something like self._interpolation.before_get(self, section, option,
> value, d) could be better written as
> self._interpolation.before_get(parser=self, ...)
Yep, that's roughly what I was trying to explain.
> I still don't g
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue9938>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
Isn't the difference between generator expressions and comprehensions what's
dealt with by PEP479? So it seems this issue is outdated enough to deserve
being closed?
--
nosy: +wolma
___
Python trac
Wolfgang Maier added the comment:
Mark, PEP479 is not fully in effect in 3.6 yet. 3.7 will raise the
RuntimeError, but 3.6 still only gives a DeprecationWarning.
--
___
Python tracker
<http://bugs.python.org/issue14
Wolfgang Maier added the comment:
running with "-W always":
>>> def five(x):
... for _ in range(5):
... yield x
...
>>> F = five('x')
>>> [next(F) for _ in range(10)]
Traceback (most recent call last):
File "", line 1,
Wolfgang Maier added the comment:
Just found issue15451, which reports a similar inconsistency between Windows
and POSIX for 'PATH' provided through the Popen env parameter as for cwd. It
seems that, on POSIX-platforms, the PATH environment variable passed through
env affects the
Changes by Wolfgang Maier :
--
title: Use argparse in the profile/cProfile modules -> calendar
___
Python tracker
<http://bugs.python.org/issue18971>
___
___
Py
Wolfgang Maier added the comment:
oops, typing in wrong window. Very sorry.
--
nosy: +wolma
title: calendar -> Use argparse in the profile/cProfile modules
___
Python tracker
<http://bugs.python.org/issu
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue28859>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
What's the justification for this proposed change? Isn't it better to report
the fact that there isn't an unambiguous result instead of returning a rather
arbitrary one?
--
nosy: +steven.daprano, wolma
versions: +Python
Wolfgang Maier added the comment:
To me this issue seems quite related to PEP 538. Maybe the LC_CTYPE coercion
proposed in the PEP could be extended to cover the case of LC_CTYPE=UTF-8?
--
nosy: +ncoghlan
versions: +Python 3.7
___
Python tracker
Wolfgang Maier added the comment:
I think PEP 538 extended to the UTF-8 locale *would* help here. Specifically,
it would coerce only LC_CTYPE to en_US.UTF-8 (unless OS X has C.UTF-8), which I
guess is good enough for the purpose here.
I do agree that it is not the kind of problem that PEP 538
Wolfgang Maier added the comment:
I studied the github PR and thought about it carefully, and that made me come
to believe that the chapter deserves a larger rewrite not just of one section,
but of several.
I'm attaching my proposed change as a "classical" patch here for disc
Wolfgang Maier added the comment:
> [...] I prefere the chapter as it currently is, because IMHO it
> introduces the concepts more gradually than your proposal.
That's ok! It's your PR and I only wanted to show an alternative.
I was hoping for a bit more people to provide feedb
New submission from Wolfgang Maier:
As a result of Issue14285 Python 3.5.2 now imports packages in runpy.
_get_module_details before calling importlib.util.find_spec.
Although I'm not sure how important this is, I wanted to report that this new
behaviour can have a side-effect under p
Wolfgang Maier added the comment:
@Martin and regarding Python3.3: Right, you cannot do the replacement when
running the module as __main__. For my use case that's not required though so
in
the module I can just do:
if __name__ == '__main__':
print('running modul
Wolfgang Maier added the comment:
A warning like this sounds good to me though I'd prefer it to be slightly more
verbose, like:
"RuntimeWarning: '' found in sys.modules after import of package
'', but prior to execution of '' as '__main__'; t
Wolfgang Maier added the comment:
It doesn't seem to be the exact same problem, but still this very simple
example with parentheses in metavar fails to format correctly:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfiles", metavar = 'i
Wolfgang Maier added the comment:
am I correct that when a script contains a shebang line like:
#! python3
or
#! python3.4
i.e., one indicating just a version of, but not a full path to the interpreter,
the current patch would not use an active virtualenv even if it has a suitable
version
Wolfgang Maier added the comment:
isn't the pyvenv.cfg file specifying the version ?
--
___
Python tracker
<http://bugs.python.org/issue23465>
___
___
Pytho
Wolfgang Maier added the comment:
> Hmm, I didn't know that (although virtualenv-based environments don't have an
> equivalent to pyvenv.cfg).
Well, that complicates things then :(
> But there's some confusion here. This patch only affects command line usage
>
Wolfgang Maier added the comment:
>> So, with the current patch users could still not use the py launcher from a
>> virtual environment with scripts that are supposed to work under UNIX :(
>
> Correct. That's not the problem this PEP is intended to solve.
Granted :)
New submission from Wolfgang Maier:
from the console:
> py -3.7
or any other not installed Python version gives:
Requested Python version (3.7) not installed
However, when the launcher is executed from python via subprocess.Popen:
>>>import subprocess
>>>p=subproce
Wolfgang Maier added the comment:
> The error() function in PC/launcher.c should call exit(rc) instead of
> ExitProcess(rc). This allows the CRT to terminate properly and flush the
> stderr FILE stream.
Interesting. Why do you need to flush stderr? I would have expected it to be
u
Wolfgang Maier added the comment:
works for me too on Windows:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> u'a\nb£'
Wolfgang Maier added the comment:
oh and documentation is here:
https://docs.python.org/3.5/library/stdtypes.html?highlight=bytes.splitlines#bytes.splitlines
--
___
Python tracker
<http://bugs.python.org/issue26
Wolfgang Maier added the comment:
Your two suggestions prompted me to do a speed comparison between them and the
result surprised me.
I tried:
import random
nums = [random.randint(0, 255) for n in range(1000)]
then timed the simple:
for n in nums:
hx = '%X' % n # or hx
Wolfgang Maier added the comment:
Ah, but it's not that format() is slower in 3.5, but that %-formatting got
faster.
It looks as if it got optimized and I was wondering whether the same
optimization could be applied to format().
--
___
P
Wolfgang Maier added the comment:
> Hum, python3 looks faster on this dummy microbenchmark yeah. Who said that
> Python 3 is slower? :-)
If you're alluding to that seemingly endless thread over on python-list, let me
say that it is not my motivation to start anything like that
Wolfgang Maier added the comment:
ping?
Just ran into this issue on OS X El Capitan with Region set to Germany and
Language to English. Just as Ned pointed out 2 years ago, this results in
LC_CTYPE set to 'UTF-8' in the terminal and docutils still can't cope with it.
Wolfgang Maier added the comment:
Given your comment about sum((fullacount & fullbcount).values()), why not use
its in-place version:
fullacount &= fullbcount
matches = sum(fullacount.values())
?
--
nosy: +wolma
___
Python tracke
New submission from Wolfgang Maier:
I thought I'd go back to work on a test patch for issue21560 today, but now I'm
puzzled by the explicit handling of memoryviews in gzip.GzipFile.write.
The method is defined as:
def write(self,data):
self._check_closed()
if
Changes by Wolfgang Maier :
--
keywords: +patch
Added file: http://bugs.python.org/file38521/memoryview_write.patch
___
Python tracker
<http://bugs.python.org/issue23
Wolfgang Maier added the comment:
Here is a patch with memoryview tests.
Are tests and code patches supposed to go in one file or separate ones ?
--
Added file: http://bugs.python.org/file38526/test_memoryview_write.patch
___
Python tracker
<h
Wolfgang Maier added the comment:
@Serhiy:
Why would data = data.cast('B') be required ? When would the memoryview not be
in 'B' format already ?
--
___
Python tracker
<http://bug
Wolfgang Maier added the comment:
> memoryview is converted to bytes because len() for memoryview returns a size
> of first dimension (a number of items for one-dimension view), not a number
> of bytes.
>
>>>> m = memoryview(array.array('I', [1, 2, 3]))
Wolfgang Maier added the comment:
Thanks everyone for the lively discussion !
I like Serhiy's idea of making write work with arbitrary objects supporting the
buffer protocol. In fact, I noticed before that GzipFile.write misbehaves with
array.array input. It pretends to accept that
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue23700>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
I think this is a consequence of PEP380 and its decision to finalize the
subgenerator when the delegating generator is closed.
Consider this simple example without tempfile:
def yielder (fileobj):
yield from fileobj
with open('some_test_file',
Wolfgang Maier added the comment:
Actually, its scary that use of yield from can have such a subtle side-effect.
Maybe PEP380 should have taken this more seriously?
--
___
Python tracker
<http://bugs.python.org/issue23
Wolfgang Maier added the comment:
@Serhiy
in this line of code:
reader = csv.DictReader(fileobj, fieldnames=next(csv.reader(fileobj)))
csv.reader(fileobj) returns the generator created by fileobj.__iter__, but no
reference to it is kept so the object gets destroyed right afterwards. This
Wolfgang Maier added the comment:
@bkabrda
not sure, but it may have to do with when exactly the object gets garbage
collected
--
___
Python tracker
<http://bugs.python.org/issue23
Wolfgang Maier added the comment:
ok, I've prepared a patch including tests based on my last suggestion, which I
think is ready for getting reviewed.
--
Added file: http://bugs.python.org/file38600/write_bytes_like_objects.patch
___
Python tr
Wolfgang Maier added the comment:
The patch has a huge block replacement in the gzip.py module starting at
GzipFile.write, which makes it large and hard to identify changes. Could that
be ameliorated or is it too much work right now?
--
nosy: +wolma
Wolfgang Maier added the comment:
so let's look at this step-by-step (and I hope I fully understood this myself):
- calling fileobj.__iter__ creates a generator because the method uses yield
from
- that generator does not get assigned to any reference so it will be
garbage-collected
-
Wolfgang Maier added the comment:
You are probably right that the io classes are broken.
>From https://docs.python.org/3/library/stdtypes.html#iterator-types:
Once an iterator’s __next__() method raises StopIteration, it must continue to
do so on subsequent calls. Implementations that do
Wolfgang Maier added the comment:
OTOH, it would be very hard to change the way fileobjects compared to designing
yield from differently so I'd still blame it partly.
Maybe it is unfortunate that generators have a close method instead of, say,
__cl
Wolfgang Maier added the comment:
> - I haven't seen other requests for it
For the record, an Extend custom action class is one of very few such classes I
have ever written for argparse for exactly the OP's usecase, i.e., it is useful
for any parser that should accept the same op
Wolfgang Maier added the comment:
Here is a revised version of my patch addressing Serhiy's review comments.
--
Added file: http://bugs.python.org/file38639/write_bytes_like_objects_v2.patch
___
Python tracker
<http://bugs.python.org/is
Changes by Wolfgang Maier :
Added file: http://bugs.python.org/file38650/write_bytes_like_objects_v3.patch
___
Python tracker
<http://bugs.python.org/issue23688>
___
___
Wolfgang Maier added the comment:
ouch. haven't thought of this.
OTOH, just plain io with your example:
with open('xy', 'wb') as f:
f.write(y)
Traceback (most recent call last):
File "", line 2, in
f.write(y)
BufferError: memoryview: underlying bu
Wolfgang Maier added the comment:
to preserve compatibility:
there is the memoryview.c_contiguous flag. Maybe we should just check it and if
it is False fall back to the old copying behavior ?
--
___
Python tracker
<http://bugs.python.
Wolfgang Maier added the comment:
something like:
def write(self,data):
self._check_closed()
if self.mode != WRITE:
import errno
raise OSError(errno.EBADF, "write() on read-only GzipFile object")
if self.fileobj is None:
Wolfgang Maier added the comment:
Serhiy:
I think I saw that you committed this also to the 2.7 branch, but that would
not work since memoryviews do not have the nbytes attribute (they do not seem
to have cast either). One would have to calculate the length instead from other
properties
Wolfgang Maier added the comment:
I see now that it is just issue21560 that went into 2.7 and that's fine.
As I said: sorry for the noise
--
___
Python tracker
<http://bugs.python.org/is
Wolfgang Maier added the comment:
actually, I'm not sure whether formatting Decimals gives correct output under
all conditions (correctly rounded yes, but maybe not formatted correctly?).
compare:
>>> format(float('1.481e-6'),'.3g')
'1.48e-0
Wolfgang Maier added the comment:
> Decimal formatting intentionally differs from float formatting, see #23460.
I see. Thanks for the pointer. What about the missing zero in the exponent ?
--
___
Python tracker
<http://bugs.python.org/issu
Wolfgang Maier added the comment:
>This implies sum() should accept str, unicode, list, tuple, bytearray, buffer,
>and xrange.
and in fact it *does* accept all these as input. It just refuses to add the
elements of the sequence if these elements are of certain types. Of course, the
el
Wolfgang Maier added the comment:
Initially, I also thought that this should be addressable with
Fraction.__round__ or an optimized variation of it, but Tuomas is right that it
gets complicated by the fact that you need to cope with the different format
specifiers and not all of them fit the
Wolfgang Maier added the comment:
the new test:
test_exc('%x', '1', TypeError, "%x format: a number is required, not str")
expects the wrong error message.
python -m unittest -v test.test_format
...
'%x' % '1' works? ... no
Unexpect
Wolfgang Maier added the comment:
I'm able to reproduce this with Python 2.7.6 on Linux, but not 2.7.9 on Windows.
Is this a POSIX-only bug or has it been fixed in the meantime ?
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/is
Wolfgang Maier added the comment:
are you looking for:
struct.pack('i'*4, *[0]*4)
?
--
nosy: +wolma
___
Python tracker
<http://bugs.python.o
Wolfgang Maier added the comment:
I'm afraid you lost me and I do not see what your problem is here.
Maybe you should raise this on one of the Python mailing lists (see
https://www.python.org/community/lists/) ?
--
___
Python tracker
Changes by Wolfgang Maier :
--
nosy: -wolma
___
Python tracker
<http://bugs.python.org/issue23933>
___
___
Python-bugs-list mailing list
Unsubscribe:
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue5680>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Wolfgang Maier:
numbers.Rational defines __float__ like this:
def __float__(self):
"""float(self) = self.numerator / self.denominator
It's important that this conversion use the integer's "true"
division rather than castin
Wolfgang Maier added the comment:
Also happening with Python 3.4.0 on Ubuntu 14.04 (after ~ half a minute and A
LOT of output):
[skipping lots of lines]
buf2: 29 13 bytearray(b'12312345678901231234567890123')
buf1: 25 9 bytearray(b'2345678901231234567890123')
bu
Wolfgang Maier added the comment:
Surprisingly, a much simpler version with just one bytearray seems to run
stably (for several minutes at least), but when you wait a while then hit
Ctrl-C, you are getting a Segmentation fault:
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on
Wolfgang Maier added the comment:
Good point.
If the numbers ABC guaranteed numerator and denominator to be Integral numbers,
this could be solved by:
return float(int(self.numerator) / int(self.denominator))
but since both could be Rationals again that does not seem to be an option
either
Wolfgang Maier added the comment:
> Is it not reasonable to simply say that implementations of numbers.Rational
> which allow the numerator and denominator to have types for which true
> division doesn't return a float, have to provide their own implementation of
> __float__(
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue23356>
___
___
Python-bugs-list mailing list
Unsubscribe:
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue22881>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
for the even number case, I think you shouldn't do // 2, but / 2.
In general, wouldn't it be good to let the statistics module do all the stats
calculations?
--
___
Python tracker
<http://bu
Wolfgang Maier added the comment:
> It's not available in older Python versions, e.g. 2.6.
I know, I was talking about 3.5+, of course. This would not be backported to
Python2 anyway, would it?
--
___
Python tracker
<http://bugs
Wolfgang Maier added the comment:
ah sorry, it's late here already and I forgot what file this change is about.
So forget my last comment then.
--
___
Python tracker
<http://bugs.python.org/is
Wolfgang Maier added the comment:
After considering this for a while, I think:
return float(self.numerator / self.denominator)
is the best solution:
* it is simple and works reasonably well as a default
* it fixes Rational.__float__ for cases, in which numerator / denominator
returns a
Changes by Wolfgang Maier :
Removed file: http://bugs.python.org/file39220/statistics._sum.patch
___
Python tracker
<http://bugs.python.org/issue24068>
___
___
Python-bug
Changes by Wolfgang Maier :
Added file: http://bugs.python.org/file39221/statistics._sum.patch
___
Python tracker
<http://bugs.python.org/issue24068>
___
___
Python-bug
New submission from Wolfgang Maier:
the mean function in the statistics module gives nonsensical results with
boolean values in the input, e.g.:
>>> mean([True, True, False, False])
0.25
>>> mean([True, 1027])
0.5
This is an issue with the module's internal _sum funct
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue8538>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
uploading an alternate, possibly slightly clearer version of the patch
--
Added file: http://bugs.python.org/file39269/statistics._sum.v2.patch
___
Python tracker
<http://bugs.python.org/issue24
Changes by Wolfgang Maier :
--
nosy: +wolma
___
Python tracker
<http://bugs.python.org/issue28115>
___
___
Python-bugs-list mailing list
Unsubscribe:
Wolfgang Maier added the comment:
STINNER Victor added the comment:
>BUT when Python is started from a virtual environment (created by the
>"venv" module), the re module is important by default.
>
>haypo@speed-python$ venv/bin/python3 -c 'import sys; print("re&quo
101 - 200 of 209 matches
Mail list logo