[issue22676] Creating the string representation of a module is slower

2014-10-21 Thread Georg Brandl
Georg Brandl added the comment: HasAttr would just call GetAttr and discard the exception. @ OP: what objects are you pickling? You can give them a __module__ attribute to save the lookup in sys.modules. -- nosy: +georg.brandl ___ Python tracker

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: There's no doubt that whichmodule() has grown more complex since 3.2. We probably cannot eliminate the O(number of modules) component, but could at least make it faster. -- stage: - needs patch title: Creating the string representation of a module is

[issue22683] bisect index out of bounds issue

2014-10-21 Thread Paul Ianas
New submission from Paul Ianas: The precondition for all the bisect functions is implemented like this: if lo 0: raise ValueError('lo must be non-negative') if hi is None: hi = len(a) Now, of course, if hi is given, and hi = 2 * len(a), then we get an IndexError. In

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Note the problem is easily reproduce. For example we can take numpy where some ufuncs (i.e. function-like objects implemented in C) don't have a __module__. $ PYTHONHASHSEED=0 python3.4 -m timeit -s import pickle, numpy; d=numpy.add pickle.dumps(d) 1000

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Georg Brandl
Georg Brandl added the comment: Attached patch addresses the repeated __repr__ calling and gives a 4x speedup here. -- keywords: +patch Added file: http://bugs.python.org/file36985/whichmodule_speedup.diff ___ Python tracker rep...@bugs.python.org

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Actually, numpy.add takes a different path. Sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22676 ___

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: So, a proper way to reproduce it is through Ellipsis (which does go through whichmodule()): $ PYTHONHASHSEED=0 python3.4 -m timeit -s import pickle; d=Ellipsis pickle.dumps(d) 1000 loops, best of 3: 201 usec per loop --

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: For example we can take numpy where some ufuncs (i.e. function-like objects implemented in C) don't have a __module__. Oh. I was not aware of that. Is there a way to fix numpy to set the __module__ attribute? Maybe we should warn users that serialiaing

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: whichmodule_speedup.diff: I proposed once a more generic solution which is much more complex to implement. Lazy formatting of Exception message: in most cases, the message is not used. Replace AttributeError(message) with AttributeError(attr=name), only

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Victor, see https://github.com/numpy/numpy/issues/4952 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22676 ___

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Attached patch produces a 8x speedup on Ellipsis. -- Added file: http://bugs.python.org/file36986/whichmodule.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22676

[issue22676] _pickle's whichmodule() is slow

2014-10-21 Thread Georg Brandl
Georg Brandl added the comment: I didn't have numpy anyway, I tested on a function with __module__ set to None manually. But I see the same speedup for Ellipsis. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22676

[issue22683] bisect index out of bounds issue

2014-10-21 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +rhettinger, tim.peters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22683 ___ ___

[issue22660] Review ssl docs for security recommendations

2014-10-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset 6f6e56bb10aa by Antoine Pitrou in branch '2.7': Issue #22660: update various mentions in the ssl module documentation. https://hg.python.org/cpython/rev/6f6e56bb10aa -- ___ Python tracker

[issue22660] Review ssl docs for security recommendations

2014-10-21 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22660 ___

[issue22607] find by dichotomy the failing test

2014-10-21 Thread Xavier de Gaye
Xavier de Gaye added the comment: The attached patch adds the '-X' and '-Y' options to the regrtest tool, allowing to select a range of tests and a range of their subtests. The patch is missing the test cases for the moment. Limitation: Does not work very well with nested subtest (nested

[issue22684] message.as_bytes() produces recursion depth exceeded

2014-10-21 Thread Pas
New submission from Pas: Please see the attached traceback (or this http://pastebin.com/WYinRGie for fancy colors). It depends on message size, we're trying to send Multipart MIME messages (a PDF attached, that has an image embedded). After editing flask_mail.py to use the fallback (

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread wabu
New submission from wabu: using `p = create_subprocess_exec(..., stdout=subprocess.PIPE, limit=...)`, p.stdout has not transport set, so the underlying protocol is unable to pause the reading of the transport, resulting in high memory usage when slowly consuming input from p.stdout, even if

[issue22684] message.as_bytes() produces recursion depth exceeded

2014-10-21 Thread R. David Murray
R. David Murray added the comment: It looks like a bug, but I'm not sure why as_bytes would trigger it but not as_string. Can you supply a copy of the message that fails? The as_string version (assuming the content was all ascii) should be enough to reproduce the issue, since it appears to

[issue22686] random.randint does not include endpoint

2014-10-21 Thread FH
New submission from FH: Upon inspection, random.randint(a,b) does not include the endpoint b, contrary to documentation, and contrary to the argumentation in Issue7009. To see this, run e.g. sum(np.random.randint(0,1,1000)) which will return 0 repeatedly (statistically very unlikely). I tried

[issue22686] random.randint does not include endpoint

2014-10-21 Thread Mark Dickinson
Mark Dickinson added the comment: You seem to be confusing `np.random.randint`, which is a function from NumPy (not part of core Python), with `random.randint` from the standard library. NumPy's np.random.randint does not include the endpoint. Python's does. As far as I can tell, the

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: p = create_subprocess_exec(..., stdout=subprocess.PIPE, limit=...) I don't see yield from. Do you wait until the coroutine completes? See the documentation: https://docs.python.org/dev/library/asyncio-subprocess.html#subprocess-using-streams Please write a

[issue22687] horrible performance of textwrap.wrap() with a long word

2014-10-21 Thread Piotr Engelking
New submission from Piotr Engelking: Wrapping a paragraph containing a long word takes a lot of time: $ time python3 -c 'import textwrap; textwrap.wrap(a * 2 ** 16)' real3m14.923s user3m14.792s sys 0m0.016s $ A straightforward replacement is 5000 times faster: $ time python3 -c

[issue22687] horrible performance of textwrap.wrap() with a long word

2014-10-21 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +georg.brandl, serhiy.storchaka versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22687 ___

[issue22688] Use the subprocess module in the uuid module

2014-10-21 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: There is a proposition (msg229163) to use the subprocess module instead of os.popen() in the uuid module. I hesitate how classify this issue (behavior, security or enhancement) and for which versions target it. May be this is a dependency of issue17293.

[issue22687] horrible performance of textwrap.wrap() with a long word

2014-10-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This particular case is related to the behavior of the wordsep_re regular expression in worst case. When text contains long sequence of words characters which is not ended by a hypen, or long sequence of non-word and non-space characters (and in some other

[issue22506] `dir` on Enum subclass doesn't expose parent class attributes

2014-10-21 Thread Ram Rachum
Ram Rachum added the comment: Thanks for the fix Ethan. Will you also push this to the backport on PyPI? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22506 ___

[issue22688] Use the subprocess module in the uuid module

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: Did you see my issue which has a patch? http://bugs.python.org/issue22637 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22688 ___

[issue22506] `dir` on Enum subclass doesn't expose parent class attributes

2014-10-21 Thread Ethan Furman
Ethan Furman added the comment: Thanks for the reminder! ... Done. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22506 ___ ___

[issue22506] `dir` on Enum subclass doesn't expose parent class attributes

2014-10-21 Thread Ram Rachum
Ram Rachum added the comment: Thanks! Two questions: 1. Is there a GitHub repo for enum34? Couldn't find a link to it on the PyPI page. 2. Aren't 'name' and 'value' already included in `added_behavior`? -- ___ Python tracker

[issue22506] `dir` on Enum subclass doesn't expose parent class attributes

2014-10-21 Thread Ram Rachum
Ram Rachum added the comment: Also, aren't you excluding a lot of important magic methods from that `dir`? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22506 ___

[issue22688] Use the subprocess module in the uuid module

2014-10-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Oh, I missed it. Thank you for opening the issue and writting the patch. -- resolution: - duplicate stage: needs patch - resolved status: open - closed superseder: - avoid using a shell in uuid: replce os.popen with subprocess.Popen

[issue22637] avoid using a shell in uuid: replce os.popen with subprocess.Popen

2014-10-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Besides few nitpicks the patch LGTM. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22637 ___

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread wabu
wabu added the comment: Sorry for the confusion, yes i do the yield from. The stdout stream for the process is actually producing data as it should. The subprocess produces a high amount of data (pbzip2), but is only consumed slowly. Normally when the buffer limit is reached for a stream

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread Guido van Rossum
Guido van Rossum added the comment: Hm... It does look like there's nothing that tells stdout (which is a StreamReader) about its transport. Wabu, could you experiment with a change to asyncio/subprocess.py where SubprocessStreamProtocol.connection_made() calls

[issue22506] `dir` on Enum subclass doesn't expose parent class attributes

2014-10-21 Thread Ethan Furman
Ethan Furman added the comment: 1. Is there a GitHub repo for enum34? Couldn't find a link to it on the PyPI page. The repo is at: https://bitbucket.org/stoneleaf/enum34 2. Aren't 'name' and 'value' already included in `added_behavior`? They didn't used to be, but they are now. I'll

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread wabu
wabu added the comment: Here's a more complete example @coroutine put_data(filename, queue, chunksize=16000): pbzip2 = yield from asyncio.create_subprocess_exec( 'pbzip2', '-cd', filename, stdout=asyncio.subprocess.PIPE, limit=self.chunksize*2) while

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread Guido van Rossum
Guido van Rossum added the comment: Can you confirm that this patch fixes the problem (without you needing the workaround in your own code)? -- keywords: +patch Added file: http://bugs.python.org/file36989/fix22685.patch ___ Python tracker

[issue22637] avoid using a shell in uuid: replce os.popen with subprocess.Popen

2014-10-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8ee63d0bd7b8 by Victor Stinner in branch 'default': Issue #22637: avoid using a shell in uuid https://hg.python.org/cpython/rev/8ee63d0bd7b8 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread wabu
wabu added the comment: thanks a lot, the fix works! On 21.10.2014 22:16, Guido van Rossum wrote: Guido van Rossum added the comment: Can you confirm that this patch fixes the problem (without you needing the workaround in your own code)? -- keywords: +patch Added file:

[issue22506] `dir` on Enum subclass doesn't expose parent class attributes

2014-10-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset 9038b63dad52 by Ethan Furman in branch 'default': Issue22506: remove name value from __dir__ as they now show up automatically https://hg.python.org/cpython/rev/9038b63dad52 -- ___ Python tracker

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread Guido van Rossum
Guido van Rossum added the comment: Victor, do you think this needs a unittest? It seems kind of difficult to test for whether memory fills up (the machine may get wedged if it does :-). On Tue, Oct 21, 2014 at 1:39 PM, wabu rep...@bugs.python.org wrote: wabu added the comment: thanks a

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: Oh ok, now I understood the issue :-) Attached patch should fix it. It implements Guido's suggestion. There is not unit test yet. -- Added file: http://bugs.python.org/file36990/set_transport.patch ___ Python

[issue22689] Posix getenv makes no guarantee of lifetime of returned string

2014-10-21 Thread Aidan Hobson Sayers
New submission from Aidan Hobson Sayers: Posix says the following on the subject of getenv: The returned string pointer might be invalidated or the string content might be overwritten by a subsequent call to getenv() (http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html)

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: test_pause_reading.py: manual test for pause reading. It should pause reading stdout pipe 4 times on UNIX. -- Added file: http://bugs.python.org/file36991/test_pause_reading.py ___ Python tracker

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread STINNER Victor
STINNER Victor added the comment: Ok, I just missed completly the Guido posted a patch before me... Maybe we wrote the patch at the same time, I didn't refresh my browser :-) Victor, do you think this needs a unittest? It seems kind of difficult to test for whether memory fills up (the

[issue22689] Posix getenv makes no guarantee of lifetime of returned string

2014-10-21 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo versions: -Python 3.2, Python 3.3, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22689 ___

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread wabu
wabu added the comment: On 21.10.2014 22:41, Guido van Rossum wrote: Guido van Rossum added the comment: Victor, do you think this needs a unittest? It seems kind of difficult to test for whether memory fills up (the machine may get wedged if it does :-). You could setup a the subprocess

[issue22687] horrible performance of textwrap.wrap() with a long word

2014-10-21 Thread Ben Roberts
Changes by Ben Roberts bjr.robe...@gmail.com: -- nosy: +roippi ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22687 ___ ___ Python-bugs-list

[issue22689] Posix getenv makes no guarantee of lifetime of returned string

2014-10-21 Thread Aidan Hobson Sayers
Aidan Hobson Sayers added the comment: In case it matters, I'm compiling using Emscripten which implements getenv like so: https://github.com/kripken/emscripten/blob/1.25.2/src/library.js#L3323 (I personally think it's a bizarre way to do it, but technically I think it's ok?) --

[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2014-10-21 Thread Guido van Rossum
Guido van Rossum added the comment: Victor, your fix is identical to mine except for the variable names. I like your version better. :-) So now it's just about the unittest. -- ___ Python tracker rep...@bugs.python.org

[issue22690] importing Gtk breaks strptime

2014-10-21 Thread Sigz
New submission from Sigz: I usually convert date string to time with strptime formating. I noticed importing Gtk breaks strptime parsing for abbreviated month name and weekday name : import time time.strptime(Mon, 20 Oct 2014 08:00:32 +, %a, %d %b %Y %H:%M:%S %z)

[issue22690] importing Gtk breaks strptime

2014-10-21 Thread R. David Murray
R. David Murray added the comment: What locale are you using? Is it possible importing Gtk makes that locale operative? (In which case, that would be a bug in either Gtk or its wrapper). -- nosy: +r.david.murray ___ Python tracker

[issue22691] A Better Help File

2014-10-21 Thread James
New submission from James: Just the General Help that is in Python, doesn't really help. Here's what would help, if every Module, had an example in code of how it was used instead of the Trees. I mean, word trees, well that's what the writing reminds me of, is word trees like you'd produce

[issue22691] A Better Help File

2014-10-21 Thread James
James added the comment: Just the General Help that is in Python, doesn't really help. Here's what would help, if every Module, had an example in code of how it was used instead of the Trees. I mean, word trees, well that's what the writing reminds me of, is word trees like you'd produce in