[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread Alexander Marshalov
Alexander Marshalov added the comment: Hi all, this is my first patch to Python. I'm interested in the performance of python code, I even worked on the development of the static optimizer based on modifications of the AST. I had a few ideas for improving peepholer (for example, the expression

[issue15984] Wrong documentation for PyUnicode_FromObject() and PyUnicode_FromEncodedObject()

2016-04-09 Thread Martin Panter
Changes by Martin Panter : Added file: http://bugs.python.org/file42419/from_object_v3.patch ___ Python tracker ___

[issue15984] Wrong documentation for PyUnicode_FromObject() and PyUnicode_FromEncodedObject()

2016-04-09 Thread Martin Panter
Changes by Martin Panter : Removed file: http://bugs.python.org/file42418/from_object_v3.patch ___ Python tracker ___

[issue15984] Wrong documentation for PyUnicode_FromObject() and PyUnicode_FromEncodedObject()

2016-04-09 Thread Martin Panter
Martin Panter added the comment: Here is a modified patch that avoids “coercion” and is hopefully more explicit. I also fixed the comment in Include/unicodeobject.h. -- nosy: +martin.panter stage: needs patch -> patch review versions: +Python 3.5, Python 3.6 -Python 3.3, Python 3.4

[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread Nick Coghlan
Nick Coghlan added the comment: Nice work on getting this running, Alexander. However, as Victor and Raymond noted, we're looking to head in a different direction with our bytecode optimisation efforts, which is to better support pluggable AST level optimisations that can make more

[issue25609] Add a ContextManager ABC and type

2016-04-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5c0e332988b2 by Martin Panter in branch 'default': Issue #25609: Double back-ticks to avoid “make check” buildbot failure https://hg.python.org/cpython/rev/5c0e332988b2 -- ___ Python tracker

[issue26721] Avoid socketserver.StreamRequestHandler.wfile doing partial writes

2016-04-09 Thread Martin Panter
Martin Panter added the comment: Here is a patch with my proposal. -- keywords: +patch Added file: http://bugs.python.org/file42417/buffered-wfile.patch ___ Python tracker

[issue10289] Document magic methods called by built-in functions

2016-04-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: Most of the proposed update look reasonable updates and would improve the documentation. That said, please take care to not accidentally document and unintentionally guarantee implementation details rather than language requirements (leaving freedom for

[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: AFAICT, the cases the OP listed would be rarely found in real code. Victor is correct is saying that we want to limit the scope of the peepholer to the most useful cases. He is also correct in saying that we've long desired constant folding to be moved

[issue26724] Serialize dict with non-string keys to JSON — unexpected result

2016-04-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think etrepum's comment on Aug 27, 2013 display's sound reasoning: ''' I expect that this error checking feature would be expensive to implement (both in runtime cost and lines of code). I think the most sensible thing to do would be to just mention this

[issue26726] Incomplete Internationalization in Argparse Module

2016-04-09 Thread Grady Martin
New submission from Grady Martin: The attached, teensy-weensy patch passes to gettext() a string which had previously been passed as-is. Relevant mailing list message: http://article.gmane.org/gmane.comp.python.devel/157035 -- files: argparse_i18n.patch keywords: patch messages:

[issue21069] test_fileno of test_urllibnet intermittently fails

2016-04-09 Thread Martin Panter
Changes by Martin Panter : -- resolution: -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker ___

[issue26720] memoryview from BufferedWriter becomes garbage

2016-04-09 Thread Martin Panter
Martin Panter added the comment: On further thought, I think releasing the buffer would not be the best long-term solution. I encountered this bug when wrapping custom AuditableBytesIO objects (Lib/test/test_httpservers.py) with BufferedWriter, where the raw object just saves each write()

[issue26720] memoryview from BufferedWriter becomes garbage

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Another option is to use the bytes object as internal buffer. If its refcount is == 1 (normal case), it is modified in-place, otherwise (if the reference is saved outside) new bytes object is created. -- ___

[issue26725] list() destroys map object data

2016-04-09 Thread Ned Deily
Ned Deily added the comment: This is behaving as expected. In Python 3, map() returns an iterator, so the first list(x) exhausts that iterator so that the second list(x) returns an empty list. This is a difference from Python 2 where map() returns a list. See:

[issue26725] list() destroys map object data

2016-04-09 Thread Steven Reed
New submission from Steven Reed: Example repro: Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x=map(bool,[1,0,0,1,1,0]) >>> x >>> list(x) [True, False, False, True,

[issue26724] Serialize dict with non-string keys to JSON — unexpected result

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See also https://github.com/simplejson/simplejson/issues/77 . -- nosy: +serhiy.storchaka versions: -Python 3.4 ___ Python tracker

[issue26723] Add an option to skip _decimal module

2016-04-09 Thread Chi Hsuan Yen
Chi Hsuan Yen added the comment: Regarding #20305: Now building is fine, while some runtime errors exist. I don't see reasons running ncurses on Android, so kicking those errors are not in my plan. For this change: Thanks for pointing that variable - not noticing it before. Seems I still

[issue26724] Serialize dict with non-string keys to JSON — unexpected result

2016-04-09 Thread anton-ryzhov
New submission from anton-ryzhov: JSON doesn't allow to have non-sting keys in objects, so json.dumps converts its to string. But if several keys has one string representation — we'll get damaged result as follows: >>> import json >>> json.dumps({1: 2, "1": "2"}) '{"1": 2, "1": "2"}' I think

[issue26723] Add an option to skip _decimal module

2016-04-09 Thread Stefan Krah
Stefan Krah added the comment: In any case: It is not uncommon that some C module does not build. You can disable modules in setup.py: # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] -- assignee: -> skrah resolution: ->

[issue26723] Add an option to skip _decimal module

2016-04-09 Thread Stefan Krah
Stefan Krah added the comment: I thought you solved the locale problem in #20305. So it still does not build? -- nosy: +skrah ___ Python tracker ___

[issue26723] Add an option to skip _decimal module

2016-04-09 Thread Chi Hsuan Yen
New submission from Chi Hsuan Yen: As said by Stefan Krah in http://bugs.python.org/issue23496#msg236886, Android ports can use pure python decimal module. Of course I can, but _decimal is always built and error messages are spamming. This change allow disabling _decimal from ./configure.

[issue25609] Add a ContextManager ABC and type

2016-04-09 Thread Brett Cannon
Brett Cannon added the comment: The typing changes need to be backported to 3.5 as-is to keep the files in sync. -- status: closed -> open versions: +Python 3.5 ___ Python tracker

[issue26718] super.__init__ leaks memory if called multiple times

2016-04-09 Thread Guido van Rossum
Guido van Rossum added the comment: Any uses of super() beyond the documented idioms are uninteresting, except they should not be usable as crash or DoS vectors. -- ___ Python tracker

[issue26719] More efficient formatting of ints and floats in json

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is similar issue with unneeded strings copying: issue26057. -- ___ Python tracker ___

[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you Martin. Interesting, int.from_bytes() accepts lists (and other iterables): >>> int.from_bytes([1, 2, 3], "little") 197121 Is it intentional? -- ___ Python tracker

[issue26719] More efficient formatting of ints and floats in json

2016-04-09 Thread Guido van Rossum
Guido van Rossum added the comment: Please also backport to 3.5.2... On Saturday, April 9, 2016, Raymond Hettinger wrote: > > Raymond Hettinger added the comment: > > +1 This is a nice improvement. > > -- > > ___ > Python

[issue21069] test_fileno of test_urllibnet intermittently fails

2016-04-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset 00240ddce1d0 by Martin Panter in branch '3.5': Issue #21069: Move test_fileno() from test_urllibnet and rewrite it https://hg.python.org/cpython/rev/00240ddce1d0 New changeset 4c19396bd4a0 by Martin Panter in branch 'default': Issue #21069: Merge

[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-09 Thread Martin Panter
Martin Panter added the comment: I think this patch is okay. I would have suggested “Cannot construct bytes from [. . .]” to avoid the problem with “convert”, but this message is produced in places other than the constructor, e.g. >>> int.from_bytes("str", "little") TypeError: cannot convert

[issue26609] Wrong request target in test_httpservers.py

2016-04-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset 0e19f421dc9e by Martin Panter in branch '3.5': Issue #26609: Fix HTTP server tests to request an absolute URL path https://hg.python.org/cpython/rev/0e19f421dc9e New changeset 34ebf79acd78 by Martin Panter in branch 'default': Issue #26609: Merge

[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread STINNER Victor
STINNER Victor added the comment: > Do you have any numbers on how common constant comparisons are in real code? In my experience, it almost never occur in real application. But it's common when you start with a constant propogation optimization: *

[issue26647] ceval: use Wordcode, 16-bit bytecode

2016-04-09 Thread Demur Rumed
Demur Rumed added the comment: [12:36] Could I get a code review for wordcode's 4th patchset? http://bugs.python.org/review/26647/#ps16875 ... [13:13] serprex: you'd be better off bumping the issue -- ___ Python tracker

[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread Demur Rumed
Demur Rumed added the comment: Do you have any numbers on how common constant comparisons are in real code? -- nosy: +Demur Rumed ___ Python tracker ___

[issue10289] Document magic methods called by built-in functions

2016-04-09 Thread Mark Lawrence
Changes by Mark Lawrence : -- nosy: -BreamoreBoy ___ Python tracker ___ ___

[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread SilentGhost
Changes by SilentGhost : -- nosy: +benjamin.peterson, brett.cannon, georg.brandl, haypo, ncoghlan, yselivanov stage: -> patch review ___ Python tracker

[issue25339] sys.stdout.errors is set to "surrogateescape"

2016-04-09 Thread STINNER Victor
STINNER Victor added the comment: The patch looks good to me. -- ___ Python tracker ___ ___ Python-bugs-list

[issue25339] sys.stdout.errors is set to "surrogateescape"

2016-04-09 Thread STINNER Victor
STINNER Victor added the comment: Ok, I now understand the issue. Your change looks good to me. I agree that strict error handler is good choice for PYTHONIOENCODING=ascii. -- ___ Python tracker

[issue26722] Fold compare operators on constants (peephole)

2016-04-09 Thread Alexander Marshalov
New submission from Alexander Marshalov: Missed peephole optimization: 1 > 2 -> False 3 < 4 -> True 5 == 6 -> False 6 != 7 -> True 7 >= 8 -> False 8 <= 9 -> True 10 is 11 -> False 12 is not 13 -> True 14 in (15, 16, 17) -> False 18 not in (19, 20,

[issue26720] memoryview from BufferedWriter becomes garbage

2016-04-09 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +benjamin.peterson, pitrou, serhiy.storchaka, stutzbach ___ Python tracker ___

[issue24291] wsgiref.handlers.SimpleHandler truncates large output blobs

2016-04-09 Thread Martin Panter
Martin Panter added the comment: I did not write a test case for the test suite. Doing so would probably involve too many non-trivial things, so I thought it wouldn’t be worth it: 1. A background thread or process to run a client in 2. Signal handling to trigger a partial write 3. Some way to

[issue17339] bytes() TypeError message is misleadingly narrow

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch. -- keywords: +patch nosy: +serhiy.storchaka stage: needs patch -> patch review versions: +Python 3.6 -Python 3.4 Added file: http://bugs.python.org/file42413/bytes_from_object_error_msg.patch ___

[issue26716] EINTR handling in fcntl

2016-04-09 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka added the comment: > It looks to me that interrupting fcntl can be used for implementing blocking lock with a timeout. If automatically retry fcntl() on EINTR, this will break such code. If the signal handler doesn't raise an exception, the

[issue24291] wsgiref.handlers.SimpleHandler truncates large output blobs

2016-04-09 Thread Martin Panter
Martin Panter added the comment: wfile-partial.patch tries to avoid partial writes in every relevant wfile.write() call I could find. Usually I do this by building a BufferedWriter around wfile. I propose to apply my patch to 3.5 (if people think it is reasonable). For 3.6 I opened Issue

[issue26721] Avoid socketserver.StreamRequestHandler.wfile doing partial writes

2016-04-09 Thread Martin Panter
New submission from Martin Panter: This is a follow-on from Issue 24291. Currently, for stream servers (as opposed to datagram servers), the wfile attribute is a raw SocketIO object. This means that wfile.write() is a simple wrapper around socket.send(), and can do partial writes. There is a

[issue23434] RFC6266 support (Content-Disposition for HTTP)

2016-04-09 Thread Piotr Dobrogost
Changes by Piotr Dobrogost : -- nosy: +piotr.dobrogost ___ Python tracker ___

[issue26720] memoryview from BufferedWriter becomes garbage

2016-04-09 Thread Martin Panter
New submission from Martin Panter: >>> class Raw(RawIOBase): ... def writable(self): return True ... def write(self, b): ... global written ... written = b ... return len(b) ... >>> writer = BufferedWriter(Raw()) >>> writer.write(b"blaua") 5 >>> raw =

[issue10289] Document magic methods called by built-in functions

2016-04-09 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka versions: +Python 3.6 -Python 3.4 ___ Python tracker ___

[issue13410] String formatting bug in interactive mode

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The issue for str was fixed in issue15516. The issue for unicode is not fixed yet. -- nosy: +serhiy.storchaka ___ Python tracker

[issue15516] exception-handling bug in PyString_Format

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This fixed an issue for str, but not for unicode. See issue13410. -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue26719] More efficient formatting of ints and floats in json

2016-04-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 This is a nice improvement. -- ___ Python tracker ___ ___

[issue24291] wsgiref.handlers.SimpleHandler truncates large output blobs

2016-04-09 Thread Martin Panter
Martin Panter added the comment: I suspect this bug does not affect Python 2. See my demo script wsgi-partial.py as evidence, which interrupts a 20 MB write with a signal. Jason: If you look at Python 2’s file.write() API , perhaps

[issue26716] EINTR handling in fcntl

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It looks to me that interrupting fcntl can be used for implementing blocking lock with a timeout. If automatically retry fcntl() on EINTR, this will break such code. -- ___ Python tracker

[issue26719] More efficient formatting of ints and floats in json

2016-04-09 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: Proposed patch provide more efficient solution of issue18264. Instead of creating new int or float object and then converting it to string, the patch directly uses functions that does int and float conversion to string. -- components: Extension

[issue26716] EINTR handling in fcntl

2016-04-09 Thread STINNER Victor
STINNER Victor added the comment: Oh, we forgot the fcntl module in the PEP 475. Here is a fix for Python 3.5 (and 3.6). -- keywords: +patch nosy: +serhiy.storchaka Added file: http://bugs.python.org/file42409/fcntl_eintr.patch ___ Python tracker

[issue26716] EINTR handling in fcntl

2016-04-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset 60ac28b612af by Victor Stinner in branch '3.5': Update fcntl doc: replace IOError with OSError https://hg.python.org/cpython/rev/60ac28b612af -- nosy: +python-dev ___ Python tracker

[issue21069] test_fileno of test_urllibnet intermittently fails

2016-04-09 Thread Berker Peksag
Berker Peksag added the comment: I saw test_fileno failure again on the Gentoo buildbot: http://buildbot.python.org/all/builders/x86%20Gentoo%20Installed%20with%20X%203.x/builds/459/steps/test/logs/stdio rewrite-fileno.patch looks good to me. -- nosy: +berker.peksag stage: patch

[issue16679] Add advice about non-ASCII wsgiref PATH_INFO

2016-04-09 Thread Martin Panter
Changes by Martin Panter : -- title: Wrong URL path decoding -> Add advice about non-ASCII wsgiref PATH_INFO ___ Python tracker ___

[issue26718] super.__init__ leaks memory if called multiple times

2016-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If super used __new__ instead of __init__, this issue probably wouldn't arise. I'm surprised that super is subclassable. -- nosy: +gvanrossum, serhiy.storchaka ___ Python tracker

[issue17264] Update Building C and C++ Extensions with distutils documentation

2016-04-09 Thread Berker Peksag
Berker Peksag added the comment: bad92d696866 has already been removed all Python 1.4 and 2.0 references. I fixed a markup error and two broken references. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed type: -> behavior versions: +Python 3.5, Python

[issue17264] Update Building C and C++ Extensions with distutils documentation

2016-04-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset ca6f174f5932 by Berker Peksag in branch '3.5': Issue #17264: Fix cross refs and a markup error in extending/building.rst https://hg.python.org/cpython/rev/ca6f174f5932 New changeset 7f7988ea908f by Berker Peksag in branch 'default': Issue #17264: