[issue21332] subprocess bufsize=1 docs are misleading
Martin Panter added the comment: On second thoughts maybe the idea of closing the input is not such a good idea in practice. Once you call os.close() on the file descriptor, that descriptor becomes unallocated, and I can’t see any way to prevent p.stdin.close(), Popen() context, destructors, etc from trying to close the file descriptor again. If the Python test suite is ever multithreaded (I’m not really familiar with it), that would be a real problem. In any case closing an unallocated file descriptor is a bad idea. Maybe the deadlocking version is more appropriate after all. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21332 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21332] subprocess bufsize=1 docs are misleading
akira added the comment: to be clear: the test itself doesn't use threads, `python -mtest -j0` runs tests using multiple *processes*, not threads. There is no issue. If the test were to run in the presence of multiple threads then the issue would be the *explicit* p.stdin.close() in the test (look at the patch) that may close `p.stdin.fileno()` that might be opened in another thread (unrelated to the current test) after it was closed in the test the first time. I could call `getattr(p.stdin, 'buffer', p.stdin).raw.fd = -1` to avoid trying to close the fd the second time but I don't think it is necessary. I don't think tests are expected to run in the presence of multiple threads unless they start them. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21332 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21414] Add an intersperse function to itertools
New submission from Alexander Boyd: Itertools would benefit greatly from a function (which I've named intersperse, after Haskell's equivalent) for yielding the items of an iterator with a given value placed between each. Sort of a str.join-like function, but for arbitrary sequences. Something like: list(itertools.intersperse(1, [2, 3, 4])) [2, 1, 3, 1, 4] -- messages: 217746 nosy: javawizard priority: normal severity: normal status: open title: Add an intersperse function to itertools type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15104] Unclear language in __main__ description
Éric Araujo added the comment: Docs and indexing/cross-links in 2.7 should indeed be improved. I had forgotten which of 2.6 or 2.7 added support for executing packages thanks to __main__.py files and the docs don't contain an answer that's comprehensive and easy to find. -- assignee: docs@python - eric.araujo nosy: +eric.araujo stage: patch review - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15104 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21415] Python __new__ method doc typo (it's a class and not a static method)
New submission from Jurko Gospodnetić: Doc/reference/datamodel.rst documentation states that the __new__ method is a static method (in Python, not in C!) when it is in fact a class method. A patch has been prepared in the https://bitbucket.org/jurko/cpython repository. branch: datamodel_doc_typo_fix commit: 81c5ba188805e42292c3eb9cffa56fbd5b7c6aee But it'll probably be easier for you to just change that single word directly. :-D Hope this helps. Best regards, Jurko Gospodnetić -- assignee: docs@python components: Documentation hgrepos: 245 messages: 217748 nosy: Jurko.Gospodnetić, docs@python priority: normal severity: normal status: open title: Python __new__ method doc typo (it's a class and not a static method) type: enhancement versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21415 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21415] Python __new__ method doc typo (it's a class and not a static method)
Changes by Jurko Gospodnetić jurko.gospodne...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file35130/81c5ba188805.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21415 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21415] Python __new__ method doc typo (it's a class and not a static method)
Steven D'Aprano added the comment: Actually, no, it is a staticmethod. See Guido's tutorial from way back in version 2.2: [quote] __new__ is a static method. When defining it, you don't need to (but may!) use the phrase __new__ = staticmethod(__new__), because this is implied by its name (it is special-cased by the class constructor). [end quote] https://www.python.org/download/releases/2.2.3/descrintro I believe that this explains why you have to use this idiom inside __new__ when using super(): def __new__(cls, x): super().__new__(cls, x) If __new__ were a classmethod, the first argument cls would be provided automatically. If you try making __new__ a classmethod, it breaks: py class Test: ... @classmethod ... def __new__(cls): ... pass ... py x = Test() Traceback (most recent call last): File stdin, line 1, in module TypeError: __new__() takes 1 positional argument but 2 were given whereas a staticmethod works fine. -- nosy: +steven.daprano resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21415 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21399] inspect and class methods
Stefan Krah added the comment: By default AC emits $type for class methods, see dict_fromkeys in Objects/dictobject.c. Thanks, good choice. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21399 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21415] Python __new__ method doc typo (it's a class and not a static method)
eryksun added the comment: I believe that this explains why you have to use this idiom inside __new__ when using super(): def __new__(cls, x): super().__new__(cls, x) Yes, if __new__ is defined and is a function, type_new replaces it with a staticmethod: http://hg.python.org/cpython/file/04f714765c13/Objects/typeobject.c#l2437 For example: class A: __new__ = lambda c: 0 type(vars(A)['__new__']) class 'staticmethod' A heap type that defines __new__ has tp_new set to slot_tp_new. This looks up and calls __new__, with the class inserted as the first argument: http://hg.python.org/cpython/file/04f714765c13/Objects/typeobject.c#l6036 If you use a classmethod, looking up __new__ returns a method bound to the class. When called, this inserts the class in the args yet again: http://hg.python.org/cpython/file/04f714765c13/Objects/classobject.c#l321 -- nosy: +eryksun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21415 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21401] python2 -3 does not warn about str/unicode to bytes conversions and comparisons
Brett Cannon added the comment: Yes, that's a possibility if we want to take the route and essentially prevent people from ever explicitly knowing that a str in Python 2 will be a str in Python 3 and they are okay with that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21401 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6839] zipfile can't extract file
Jim Jewett added the comment: On Fri, May 2, 2014 at 1:14 AM, Adam Polkosnik The problems documented here are related to two cases (both apparently arriving from world of windows): Good! I had thought you had even more! 1. two relative paths with inverted slash in one of them (test\test2.txt vs test/test2.txt) My understanding from earlier -- and I may have been reading too much into some of the comments -- is that the standard defined \filename as an inferior alias for /filename and supported the fix. Notably, if you're extracting on windows with windows conventions, then windows will treat them identically anyhow. If you're extracting a windows file to a unix environment, then \t really should be translated to /t. 2. relative path vs absolute path (windows\temp\test.txt vs c:\windows\temp\test.txt) These really are different, as leaving off the C: should mean current drive, which will often (but not always) be C: This (and differing capitalization) are among the reasons to do the filename fix in a separate method, so that subclasses with more local knowledge can more easily do the right thing. Note that for python 3.4 and newer, pathlib URL: https://docs.python.org/3/library/pathlib.html may be helpful. It would probably even be possible to backport the essential parts as an implementation detail. But I'm not sure if that could be done compatibly with maintenance releases, or how much work it would take. The extraction part seems to be doing a good job at writing the files into sane locations. IMHO, there's no point in trying to replace slashes or otherwise normalize, as this would fix the cases where the presence of an inverted slashes should be noted in debug output. My understanding had been that it was failing to extract entirely. So exactly what is the problem? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6839 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6839] zipfile can't extract file
Adam Polkosnik added the comment: Extraction works fine, the issue was that raise() was creating an exception, and stoping the whole extraction process. When replaced with a warning, everything works fine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6839 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18604] Consolidate gui available checks in test.support
Roundup Robot added the comment: New changeset 5f75eadecff1 by Zachary Ware in branch '2.7': Issue #18604: Consolidated checks for GUI availability. http://hg.python.org/cpython/rev/5f75eadecff1 New changeset eb361f69ddd1 by Zachary Ware in branch '3.4': Issue #18604: Consolidated checks for GUI availability. http://hg.python.org/cpython/rev/eb361f69ddd1 New changeset 82caec3865e3 by Zachary Ware in branch 'default': Closes #18604: Merge with 3.4 http://hg.python.org/cpython/rev/82caec3865e3 -- nosy: +python-dev resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18604 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6839] zipfile can't extract file
Ethan Furman added the comment: Adam Polkasnik said: Extraction works fine, the issue was that raise() was creating an exception, and stopping the whole extraction process. That doesn't make sense. If an exception was stopping the whole extraction process then extraction was not working fine. Questions: - Are the names with '\' in them in the central directory, or the per-file header? - If in the central directory (which is the name we are going to use, yes?) how do we tell if the '\' should be a '/' or an escape? (such as '\t') -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6839 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14019] Unify tests for str.format and string.Formatter
Francisco Martín Brugué added the comment: The formatter module was deprecated in Python 3.4 and is scheduled for removal in Python 3.6. See [1] and [2]. --- [1] https://docs.python.org/3/library/formatter.html#module-formatter [2] https://docs.python.org/3/whatsnew/3.4.html#deprecated -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14019 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21414] Add an intersperse function to itertools
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21413] urllib.request.urlopen dies on non-basic/digest auth schemes
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21413 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20544] Use specific asserts in operator tests
Andrew Svetlov added the comment: LGTM. Ping? -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20544 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21347] Don't use a list argument together with shell=True in subprocess' docs
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21347 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21335] Update importlib.__init__ to reset _frozen_importlib's loader to SourceFileLoader
Brett Cannon added the comment: Even with setting SourceFileLoader, you still don't get file lines back. Why? Because all of the constructed objects in _frozen_importlib have their co_filename set before the back-patching in importlib.__init__ and so when the traceback module tries to do its thing it sees 'frozen importlib._bootstrap' as the filename instead of importlib._bootstrap.__file__ which doesn't lead to linecache getting anything useful. IOW a whole lot of effort for code that people should never have to look at. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21335 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21347] Don't use a list argument together with shell=True in subprocess' docs
akira added the comment: I've checked the same documentation patch applies to both default (3.5) and 2.7 branches. There are no more instances of the misleading usage left (after applying the patch). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21347 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21416] argparse should accept bytes arguments as originally passed
New submission from Derek Wilson: If I create an argument parser like: parser = argparse.ArgumentParser() parser.add_argument('somebytes', type=bytes, help='i want some bytes') parser.parse_args() the parse_args() call will raise an exception printing usage info indicating that an invalid bytes value was passed if any of the bytes on the command line are 127. if i'm specifying that i want bytes then i should expect that the argument should be interpreted as bytes and not text. I get that #8776 was closed because it makes sense not to clutter up internals, but in this instance i am building a command line parser and telling it exactly what i expect. if the solution from #8776 of os.fsencode(sys.argv) will definitely always work then argparse should do this internally if i tell it i expect bytes on the command line. -- components: Library (Lib) messages: 217761 nosy: underrun priority: normal severity: normal status: open title: argparse should accept bytes arguments as originally passed type: behavior versions: Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21416 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21037] add an AddressSanitizer build option
Stefan Krah added the comment: Antoine, if you send me the buildbot credentials, we can get started. Environment vars: CC=clang ASAN_OPTIONS=allocator_may_return_null=1,handle_segv=0 I suggest to compile the release build, just --with-address-sanitizer. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21037 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21397] tempfile.py: Fix grammar in docstring, comment typos
Éric Araujo added the comment: Thanks for the report and patch! I don't really see how just can be interpreted as applying to something else than below, so I'm not sure the wording needs to be changed. The typo should be fixed. -- nosy: +eric.araujo stage: - patch review versions: +Python 2.7, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21397 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21414] Add an intersperse function to itertools
Éric Araujo added the comment: I looked for a previous discussion of this on the Python mailing lists and found nothing. Existing solutions include https://twitter.com/snim2/status/393821419114483712 and http://stackoverflow.com/questions/5655708/python-most-elegant-way-to-intersperse-a-list-with-an-element Raymond is the one to decide whether this should be added. If he doesn't comment in the near future, feel free to propose this on python-ideas to see if people like it. You may also want to ask maintainers of projects like more-itertools if they have a similar function and if people use it. -- nosy: +eric.araujo, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21405] Allow using symbols from Unicode block Superscripts and Subscripts in identifiers
Éric Araujo added the comment: Many features are indeed discussed on this bug tracker, but for a big change like the one you propose we like to reach out to all of python-dev or all people on python-ideas to discuss pros and cons. The devguide should explain this in a little more detail. I don't know if the google group you posted to is a read-only or two-way mirror; the real list is found at https://mail.python.org/mailman/listinfo/python-ideas -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21405 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21405] Allow using symbols from Unicode block Superscripts and Subscripts in identifiers
Éric Araujo added the comment: FTR https://docs.python.org/devguide/#proposing-changes-to-python-itself -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21405 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21400] Code coverage documentation is out-of-date.
Éric Araujo added the comment: I think Walter is referring to Ned's coverage.py project, i.e. the standard coverage module that you get with pip install coverage. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21400 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21398] LC_CTYPE=C: pydoc leaves terminal in an unusable state
Changes by Éric Araujo mer...@netwok.org: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21398 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21404] Document options used to control compression level in tarfile
Éric Araujo added the comment: I'm reclassifying this ticket as a doc bug, would you mind opening a separate ticket for zipfile? -- assignee: - docs@python components: +Documentation -Library (Lib) keywords: +easy nosy: +docs@python, eric.araujo stage: - needs patch title: Compression level for tarfile/zipfile - Document options used to control compression level in tarfile versions: +Python 2.7, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21404 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21391] PATCH: using the abspath shortcut in Lib/shutil
Éric Araujo added the comment: IMO either change would not improve the code at all. Suggest closing this. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21391 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21417] Compression level for zipfile
New submission from Sworddragon: This is a fork from this ticket: http://bugs.python.org/issue21404 tarfile has a compression level and seems to get now the missing documentation for it. But there is still a compression level missing for zipfile. -- components: Library (Lib) messages: 217770 nosy: Sworddragon priority: normal severity: normal status: open title: Compression level for zipfile versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21417 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21417] Compression level for zipfile
Changes by Sworddragon sworddrag...@aol.com: -- type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21417 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21404] Document options used to control compression level in tarfile
Sworddragon added the comment: Sure, here is the new ticket: http://bugs.python.org/issue21417 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21404 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21368] Check for systemd locale on startup if current locale is set to POSIX
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21368 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21417] Compression level for zipfile
Changes by Éric Araujo mer...@netwok.org: -- nosy: +alanmcintyre stage: - needs patch versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21417 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21366] Document that return in finally overwrites prev value
Éric Araujo added the comment: Thanks, your proposed wording sounds good to me. David (picked you seni-randomly as a senior core dev and native speaker), what do you think? -- nosy: +eric.araujo, r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21366 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21413] urllib.request.urlopen dies on non-basic/digest auth schemes
Changes by Ned Deily n...@acm.org: -- nosy: +orsenthil versions: -Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21413 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Changes by Shawn binarycrusa...@gmail.com: -- nosy: +swalker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21391] PATCH: using the abspath shortcut in Lib/shutil
Eric V. Smith added the comment: I disagree. It took me longer than I'd like to admit to track down the file history and understand it. I'd like to prevent other people from having to try and understand why it works this way. On the other hand, it looks like people have discovered it: https://mail.python.org/pipermail/tutor/2012-August/090891.html so getting rid of it isn't so simple. If we are going to keep it, we should add a test for it (which actually might exist, I haven't checked yet). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21391 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18604] Consolidate gui available checks in test.support
Terry J. Reedy added the comment: Thank you Zach. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18604 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21366] Document that return in finally overwrites prev value
R. David Murray added the comment: The precisionist in me isn't quite happy, but any wording I've come up with to make it more precise isn't as informative :) (The 'real' situation is that the return value of the function is determined by the last return statement executed, which in turn is determined by the try/finally logicbut as far as I can see the suggested phrasing is equivalent to that in every respect that matters). I also have an impulse to add so don't do that :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21366 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21368] Check for systemd locale on startup if current locale is set to POSIX
Stefan Krah added the comment: Why is the default encoding of POSIX wrong on a modern Linux system? Today I installed Debian testing, and the first question of the installer is to choose between C and English locales for the install. This with the remark that the chosen locale will be the default system locale. -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21368 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21418] Segv during call to super_init in application embedding Python interpreter.
New submission from Robert Snoeberger: While embedding the Python interpreter in an application, I have encountered a crash when the built-in function 'super' is invoked with no arguments. The crash occurs during a call to PyObject_Call. A file is attached, super_invoke.c, that reproduces the crash. The reproduction steps on my machine are the following: % gcc -o super_invoke super_invoke.c -I/path_to_py/include/python3.5m -L/path_to_py/lib -lpthread -ldl -lutil -lm -lpython3.5m -Xlinker -export-dynamic % ./super_invoke Call super with no arguments... Segmentation fault % The crash appears to occur in the function super_init contained in the file Objects/typeobject.c. The code path enters the if statement that checks for no input arguments. The following two lines cause the crash. PyFrameObject *f = PyThreadState_GET()-frame; PyCodeObject *co = f-f_code; The PyFrameObject pointer 'f' is NULL. -- files: super_invoke.c messages: 21 nosy: snoeberger priority: normal severity: normal status: open title: Segv during call to super_init in application embedding Python interpreter. type: crash versions: Python 3.5 Added file: http://bugs.python.org/file35131/super_invoke.c ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21418 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6839] zipfile can't extract file
Adam Polkosnik added the comment: Ethan, I'd refer you to msg92309... And When testing with WinZip it looks like this: No errors detected in compressed data of C:\Downloads\test.zip. Testing ... Testing test\OK Testing test\test2.txt OK Testing test1.txtOK Then in python: Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AM D64)] on win32 Type help, copyright, credits or license for more information. import zipfile zf = zipfile.ZipFile('test.zip') namelist = zf.namelist() namelist ['test/', 'test/test2.txt', 'test1.txt'] for af in namelist: ... zf.read(af) ... Traceback (most recent call last): File stdin, line 2, in module File c:\Python34\lib\zipfile.py, line 1117, in read with self.open(name, r, pwd) as fp: File c:\Python34\lib\zipfile.py, line 1180, in open % (zinfo.orig_filename, fname)) zipfile.BadZipFile: File name in directory 'test\\' and header b'test/' differ. So, based on that everything is already converted to forward slashes for the extraction. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6839 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21398] LC_CTYPE=C: pydoc leaves terminal in an unusable state
STINNER Victor added the comment: LC_CTYPE=C: pydoc leaves terminal in an unusable state In the use case, pydoc doesn't touch the terminal, it's the pager: the program less. I don't see how to ensure that the terminal state is restored, even on error. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21398 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21412] core dump in PyThreadState_Get when built --with-pymalloc
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21412 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21412] core dump in PyThreadState_Get when built --with-pymalloc
STINNER Victor added the comment: LD_LIBRARY_PATH=/builds/jbeck/ul-python-3/components/python/python34/build/sparcv9 ./python -E -S -m sysconfig --generate-posix-vars Fatal Python error: PyThreadState_Get: no current thread Could you please run this command in gdb and copy/paste the C traceback (gdb command where) where the fatal error occurs? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21412 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21393] Python/random.c: close hCryptProv at exit
Changes by STINNER Victor victor.stin...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21393 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py
Stefan Krah added the comment: Thanks, Ned. I'm attaching a second version of the existing patch with improved error handling and a fix for test_distutils, which failed. The result is slightly overcomplicated, so I came up with a different approach in issue21121-3.diff. Thoughts? -- Added file: http://bugs.python.org/file35133/issue21121-2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21121 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21393] Python/random.c: close hCryptProv at exit
Roundup Robot added the comment: New changeset 8704198680ba by Victor Stinner in branch 'default': Issue #21393: random.c: on Windows, close the hCryptProv handle at exit http://hg.python.org/cpython/rev/8704198680ba -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21393 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py
Changes by Stefan Krah stefan-use...@bytereef.org: Added file: http://bugs.python.org/file35134/issue21121-3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21121 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21418] Segv during call to super_init in application embedding Python interpreter.
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21418 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21398] LC_CTYPE=C: pydoc leaves terminal in an unusable state
Stefan Krah added the comment: STINNER Victor rep...@bugs.python.org wrote: I don't see how to ensure that the terminal state is restored, even on error. Python2 suppresses the exception until after normal exit (pressing 'q'). I think that behavior is better. In Python3 you can also get the unusable terminal by pressing Ctrl-C, i.e. without any UnicodeError. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21398 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21398] LC_CTYPE=C: pydoc leaves terminal in an unusable state
STINNER Victor added the comment: heapq documentation contains François which is not encodable to ASCII. When using LC_ALL=C, the locale encoding is ASCII (at least on Linux). It's not easy to specify a different error handler globally in pydoc, different functions are used and child processes are spawned. The subprocess module doesn't allow to specify an error handler different than strict (see #6135). I propose pydoc_encoding.patch which escapes manually non-encodable characters. I chose sys.getfilesystemencoding(), I'm not sure that it's the encoding used for all cases of getpager() on all platforms. For example, on Windows, sys.getfilesystemencoding() is the ANSI code page, whereas sys.stdout.encoding is the OEM code page. -- keywords: +patch Added file: http://bugs.python.org/file35132/pydoc_encoding.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21398 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21233] Add *Calloc functions to CPython memory allocation API
Roundup Robot added the comment: New changeset 5b0fda8f5718 by Victor Stinner in branch 'default': Issue #21233: Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(), http://hg.python.org/cpython/rev/5b0fda8f5718 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21233 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21233] Add *Calloc functions to CPython memory allocation API
STINNER Victor added the comment: There is no need to hurry. I changed my mind :-p It should be easier for numpy to test the development version of Python. Let's wait for buildbots. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21233 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
New submission from STINNER Victor: Attached patch modifies long_lshift() to allocate the result using calloc() instead of malloc(). The goal is to avoid allocating physical memory for the least significat digits (zeros). According to my tests in issue #21233 (calloc), Linux and Windows have an optimized calloc() functions and at least Linux avoids allocating memory for pages initialized by zeros until pages at modified. -- files: long_lshift.patch keywords: patch messages: 217787 nosy: haypo, pitrou priority: normal severity: normal status: open title: Use calloc() instead of malloc() for int int (lshift) type: performance versions: Python 3.5 Added file: http://bugs.python.org/file35135/long_lshift.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
STINNER Victor added the comment: bench_long_rshift.py: Microbenchmark for int int (lshift) operation. Results on Linux: Common platform: Bits: int=32, long=64, long long=64, size_t=64, void*=64 Timer info: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09) Python unicode implementation: PEP 393 Timer: time.perf_counter CPU model: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz Platform: Linux-3.13.9-200.fc20.x86_64-x86_64-with-fedora-20-Heisenbug CFLAGS: -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes Platform of campaign orig: SCM: hg revision=5b0fda8f5718 tag=tip branch=default date=2014-05-02 22:31 +0200 Python version: 3.5.0a0 (default:5b0fda8f5718, May 2 2014, 22:47:06) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] Date: 2014-05-02 22:47:12 Timer precision: 46 ns Platform of campaign calloc: Timer precision: 49 ns Python version: 3.5.0a0 (default:5b0fda8f5718+, May 2 2014, 22:45:58) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] Date: 2014-05-02 22:46:42 SCM: hg revision=5b0fda8f5718+ tag=tip branch=default date=2014-05-02 22:31 +0200 +-+ Tests | orig | calloc +-+ 1 (2 ** 0) | 39 ns (*) | 38 ns 1 (2 ** 1) | 38 ns (*) | 37 ns 1 (2 ** 3) | 38 ns (*) | 37 ns 1 (2 ** 5) | 42 ns (*) | 39 ns (-8%) 1 (2 ** 10) | 43 ns (*) | 37 ns (-14%) 1 (2 ** 15) | 157 ns (*) | 90 ns (-43%) 1 (2 ** 20) | 3.91 us (*) | 74 ns (-98%) 1 (2 ** 25) | 206 us (*) | 86 ns (-100%) 1 (2 ** 28) | 4.06 ms (*) | 4.1 us (-100%) 123 1 | 11 ns (*) | 12 ns 12345678 1 | 11 ns (*) | 12 ns 12345678 100 | 11 ns (*) | 11 ns +-+ Total | 4.27 ms (*) | 4.57 us (-100%) +-+ -- Added file: http://bugs.python.org/file35136/bench_long_rshift.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
Josh Rosenberg added the comment: Looks like you forgot to actually use the use_calloc parameter you put in the long_alloc prototype. It accepts it, but it's never used or passed to another function. So right now, the only difference in behavior is that there is an extra layer of function calls involved in _PyLong_New. On that note, might it make sense to change all other calls to _PyLong_New within longobject.c to use long_alloc(size, 0) to at least make long object's themselves avoid the overhead of the extra function call? Maybe I'm overestimating how much of a difference an extra C level function call will make, but it seems like PyLongs make new PyLongs an awful lot. -- nosy: +josh.rosenberg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
Josh Rosenberg added the comment: Given your benchmarks show improvements (you posted while I was typing my last comment), I'm guessing it's just the posted patch that's wrong, and your local changes actually use use_calloc? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
STINNER Victor added the comment: Without the patch, 1 (2**29) allocates 69.9 MB. With the patch, 1 (2**29) allocates 0.1 MB (104 KB). Without the patch, $ ./python Python 3.5.0a0 (default:5b0fda8f5718, May 2 2014, 22:47:06) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux import os os.system(grep RSS /proc/%s/status % os.getpid()) VmRSS: 6164 kB x=1 (2**29) os.system(grep RSS /proc/%s/status % os.getpid()) VmRSS: 76064 kB With the patch: haypo@selma$ ./python Python 3.5.0a0 (default:5b0fda8f5718+, May 2 2014, 22:55:47) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux Type help, copyright, credits or license for more information. import os os.system(grep RSS /proc/%s/status % os.getpid()) VmRSS: 5864 kB x=1 (2**29) os.system(grep RSS /proc/%s/status % os.getpid()) VmRSS: 5968 kB -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
STINNER Victor added the comment: Looks like you forgot to actually use the use_calloc parameter you put in the long_alloc prototype. It accepts it, but it's never used or passed to another function. Oh f###, you're right. See new patch. I ran again the new benchmark: my (updated) patch makes most operations slower, except for 1 (2 ** 28). For 1 (2 ** 28), it's much faster, but it is worth to modify long_lshift() for this rare use case? Updated benchmark: Common platform: Timer: time.perf_counter Timer info: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09) Platform: Linux-3.13.9-200.fc20.x86_64-x86_64-with-fedora-20-Heisenbug CPU model: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz Python unicode implementation: PEP 393 Bits: int=32, long=64, long long=64, size_t=64, void*=64 CFLAGS: -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes Platform of campaign orig: Python version: 3.5.0a0 (default:5b0fda8f5718, May 2 2014, 22:47:06) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] SCM: hg revision=5b0fda8f5718 tag=tip branch=default date=2014-05-02 22:31 +0200 Timer precision: 46 ns Date: 2014-05-02 22:47:12 Platform of campaign calloc2: Python version: 3.5.0a0 (default:5b0fda8f5718+, May 2 2014, 23:04:59) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] Date: 2014-05-02 23:05:23 SCM: hg revision=5b0fda8f5718+ tag=tip branch=default date=2014-05-02 22:31 +0200 Timer precision: 45 ns +-+ Tests | orig | calloc2 +-+ 1 (2 ** 0) | 39 ns (*) | 50 ns (+30%) 1 (2 ** 1) | 38 ns (*) | 47 ns (+22%) 1 (2 ** 3) | 38 ns (*) | 48 ns (+26%) 1 (2 ** 5) | 42 ns (*) | 50 ns (+17%) 1 (2 ** 10) | 43 ns (*) | 53 ns (+23%) 1 (2 ** 15) | 157 ns (*) | 172 ns (+10%) 1 (2 ** 20) | 3.91 us (*) | 3.95 us 1 (2 ** 25) | 206 us (*) | 218 us (+5%) 1 (2 ** 28) | 4.06 ms (*) | 4.29 us (-100%) 123 1 | 11 ns (*) | 11 ns 12345678 1 | 11 ns (*) | 11 ns 12345678 100 | 11 ns (*) | 11 ns +-+ Total | 4.27 ms (*) | 226 us (-95%) +-+ -- Added file: http://bugs.python.org/file35137/long_lshift2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
STINNER Victor added the comment: Without the patch, 1 (2**29) allocates 69.9 MB. With the patch, 1 (2**29) allocates 0.1 MB (104 KB). This is still true with long_lshift2.patch (except that in my new test, it allocates 196 kB). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21233] Add *Calloc functions to CPython memory allocation API
STINNER Victor added the comment: Antoine Pitrou wrote: The real use case I envision is with huge powers of two. If I write: x = 2 ** 100 I created the issue #21419 for this idea. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21233 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
Josh Rosenberg added the comment: While you're doing this, might it make sense to add a special case to long_pow so it identifies cases where a (digit-sized) value with an absolute value equal to a power of 2 is being raised to a positive integer exponent, and convert said cases to equivalent left shifts? Identifying powers of 2 can be done in constant time with no memory overhead for register sized values (see http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2 ); if you've already handled the case for 0, then checking if it's a power of 2 is just: (v (v - 1)) == 0 It adds a little complexity, but even just handling 2 alone specially would at least make it so the semi-common case of making a large power of 2 doesn't have significantly different performance using 2 ** (numbits - 1) instead of 1 (numbits - 1). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
Josh Rosenberg added the comment: I swear, I need to refresh before I post a long comment. If this is slowing everything down a little just to make 1 (2 ** 29) faster (and did you really mean 1 (1 29) ? :-) ), then I'd say drop it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21233] Add *Calloc functions to CPython memory allocation API
Roundup Robot added the comment: New changeset 62438d1b11c7 by Victor Stinner in branch 'default': Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to http://hg.python.org/cpython/rev/62438d1b11c7 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21233 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
Josh Rosenberg added the comment: One possible way to salvage it: Have you considered declaring long_alloc as Py_LOCAL_INLINE, or, now that I've checked #5553, a macro for long_alloc, so it gets inlined, and doesn't add the check overhead to everything (since properly inlining with a constant argument to use_calloc should make the optimizer trim the unused code path at compile time)? Probably not very PEP7 friendly to macro-ize something that long I'm guessing... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21419] Use calloc() instead of malloc() for int int (lshift)
Josh Rosenberg added the comment: And now that I'm thinking about it, the probable cause of the slowdown is that, for any PyLongObject that's smaller than PAGESIZE (give or take), using Calloc means calloc is just calling memset to zero the PyLongObject header and the used part of the high order bits along with everything else, where the original Malloc code avoided performing two passes over the memory, initializing each byte in order, and writing each one exactly once. The Calloc approach uses two passes, and the second one isn't wholly sequential, so it may be getting bit by the CPU cache not keeping up. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21419 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21420] Optimize 2 ** n: implement it as 1 n
New submission from STINNER Victor: The algorithm for 2 ** n (long_pow) is slower than 1 n algorithm (long_lshift). I propose to compute x**y as 1y if x==2 and y = 0. Attached patch implements this idea. According to my microbenchmark, it is 4x faster to small power (2**0 .. 2**1024) and up to 340x faster for large power (2**(2**28)). -- files: pow2.patch keywords: patch messages: 217800 nosy: haypo priority: normal severity: normal status: open title: Optimize 2 ** n: implement it as 1 n type: performance versions: Python 3.5 Added file: http://bugs.python.org/file35138/pow2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21420] Optimize 2 ** n: implement it as 1 n
STINNER Victor added the comment: Results of bench_pow2.py on Linux. Common platform: CPU model: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz Platform: Linux-3.13.9-200.fc20.x86_64-x86_64-with-fedora-20-Heisenbug Timer: time.perf_counter Python unicode implementation: PEP 393 Timer info: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09) CFLAGS: -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes Bits: int=32, long=64, long long=64, size_t=64, void*=64 Platform of campaign orig: Date: 2014-05-02 23:45:29 SCM: hg revision=62438d1b11c7 tag=tip branch=default date=2014-05-02 23:26 +0200 Timer precision: 49 ns Python version: 3.5.0a0 (default:62438d1b11c7, May 2 2014, 23:45:22) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] Platform of campaign pow2: Python version: 3.5.0a0 (default:62438d1b11c7+, May 2 2014, 23:47:50) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] SCM: hg revision=62438d1b11c7+ tag=tip branch=default date=2014-05-02 23:26 +0200 Timer precision: 51 ns Date: 2014-05-02 23:48:03 ---+--+ Tests | orig | pow2 ---+--+ 2 ** 0 | 40 ns (*) | 44 ns (+9%) 2 ** 1 | 264 ns (*) | 62 ns (-76%) 2 ** 3 | 270 ns (*) | 62 ns (-77%) 2 ** 5 | 269 ns (*) | 62 ns (-77%) 2 ** 10 | 278 ns (*) | 63 ns (-78%) 2 ** 15 | 299 ns (*) | 62 ns (-79%) 2 ** 20 | 287 ns (*) | 62 ns (-78%) 2 ** 25 | 302 ns (*) | 62 ns (-79%) 2 ** 28 | 293 ns (*) | 62 ns (-79%) 2 ** (2 ** 0) | 264 ns (*) | 62 ns (-77%) 2 ** (2 ** 1) | 264 ns (*) | 62 ns (-76%) 2 ** (2 ** 3) | 264 ns (*) | 62 ns (-77%) 2 ** (2 ** 5) | 286 ns (*) | 68 ns (-76%) 2 ** (2 ** 10) | 740 ns (*) | 68 ns (-91%) 2 ** (2 ** 15) | 93.1 us (*) | 180 ns (-100%) 2 ** (2 ** 20) | 3.94 ms (*) | 3.89 us (-100%) 2 ** (2 ** 25) | 154 ms (*) | 213 us (-100%) 2 ** (2 ** 28) | 1.36 sec (*) | 4.01 ms (-100%) ---+--+ Total | 1.52 sec (*) | 4.23 ms (-100%) ---+--+ -- Added file: http://bugs.python.org/file35139/bench_pow2.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21420] Optimize 2 ** n: implement it as 1 n
STINNER Victor added the comment: Oh, the patch implements another micro-optimization: (x 0) is x becomes True. I included it in the same patch to reduce the overhead for 2 ** 0. -- nosy: +josh.rosenberg, pitrou, serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21420] Optimize 2 ** n: implement it as 1 n
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21420 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21398] LC_CTYPE=C: pydoc leaves terminal in an unusable state
Stefan Krah added the comment: The patch works well BTW. We can create another issue for the general misbehavior of pydoc with other exceptions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21398 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21412] core dump in PyThreadState_Get when built --with-pymalloc
John Beck added the comment: Victor: sure; see attached. -- Added file: http://bugs.python.org/file35140/where.out ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21412 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py
Éric Araujo added the comment: I like issue21121-3.diff. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21121 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21385] Compiling modified AST crashes on debug build unless linenumbering discarded
Terry J. Reedy added the comment: 3.1 to 3.3 only get internet security patcches, and I don't believe this is such an issue. It is not clear from the title (a statement, not a request) and your text what specific patch you would like. If you want to 'reopen a discussion', please post on python-ideas. It appears that your idea is to abandon a rule that does not work. But it is not clear from a first reading exactly what alternative you want. -- nosy: +terry.reedy versions: -Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21385 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21402] tkinter.ttk._val_or_dict assumes tkinter._default_root exists
Terry J. Reedy added the comment: A reference to a non-existent attribute fails no matter who calls the function. Stephen, can you suggest a patch, perhaps based on code in other functions that try to access _default_root? -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21402 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21414] Add an intersperse function to itertools
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21352] improve documentation indexing
Éric Araujo added the comment: I have to agree the index pages are often frustrating for me too. Not sure if this involves code changes in Sphinx itself or if we can improve the markup in the Python docs sources. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21352 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__
New submission from Josh Rosenberg: Unlike the other collections ABCs, MappingView and its subclasses (Keys|Items|Values)View don't define __slots__, so users inheriting them to take advantage of the mix-in methods get a __dict__ and __weakref__, even if they try to avoid it by declaring their own __slots__. This is sub-optimal (I don't think any library class should leave __slots__ undefined, but it's particularly bad when they're intended to be used a base classes). I've attached a patch that defines __slots__ for all of them; MappingView explicitly declares its _mapping slot, and the rest declare no slots at all. Only negative I can think of is that if the user provides their own __init__, doesn't call the super().__init__, and uses a different name than _mapping for whatever data structure they actually use, then there will be a pointer reserved for _mapping that never gets set. That said, if they don't define _mapping, none of the mix-in methods work anyway, so they may as well not inherit directly, and instead just use *View.register to become a virtual subclass. -- files: slots_for_mappingview_abcs.patch keywords: patch messages: 217809 nosy: josh.rosenberg priority: normal severity: normal status: open title: ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__ Added file: http://bugs.python.org/file35141/slots_for_mappingview_abcs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21421 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__
Josh Rosenberg added the comment: Hmm... First patch isn't generating a review diff (I'm guessing because my VM's time sync went farkakte). Trying again. -- Added file: http://bugs.python.org/file35142/slots_for_mappingview_abcs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21421 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__
Changes by Josh Rosenberg shadowranger+pyt...@gmail.com: Removed file: http://bugs.python.org/file35141/slots_for_mappingview_abcs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21421 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__
Josh Rosenberg added the comment: I also wrote a slightly more thorough patch that simplifies some of the method implementations (largely just replacing a bunch of for/if/return True/False else return False/True with any/all calls against a generator expression). The one behavior difference is that I dramatically simplified Sequence's __iter__; the original just kept indexing until it got IndexError, the replacement just runs len(self) times, on the theory that a self-mutating Sequence should write its own __iter__, and we shouldn't jump through hoops to accommodate unsupported behavior like mutating a Sequence during iteration. All tests pass under both patches. -- Added file: http://bugs.python.org/file35143/collections_abc_cleanup.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21421 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14191] argparse doesn't allow optionals within positionals
paul j3 added the comment: I encountered a conflict when merging this patch with http://bugs.python.org/issue15112. In my first testcase, 'cmd' and 'rest' failed the 'required' test in phase one of 'intermixed'. That's because 15112 postponed parsing them (with nargs=0/suppressed). I got around that by temporarily setting the 'required' attribute to False. The whole issue of when (or even whether) a positional that is satisfied with 0 arguments, is consumed, is a bit messy. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21368] Check for systemd locale on startup if current locale is set to POSIX
Nick Coghlan added the comment: That's the problem - even on UTF-8 systems, Linux programs will often be started in a misconfigured environment: the POSIX locale. Python 2 doesn't try to interpret the binary data as text, so it doesn't care. Python 3 *does* care, since it automatically converts several pieces of OS provided data to text using the locale encoding. systemd tackles that by adding the extra config file to ensure *all* the environments it creates get the right config, and to provide a more reliable source of truth as to the actual likely encoding of system interfaces. However, a fair bit of groundwork is needed to avoid any innate reliance on the locale encoding before we can reliably override it by default, so this issue is unlikely to go anywhere before PEP 432 is implemented (and even then, actually changing the behaviour would be a separate discussion). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21368 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21414] Add an intersperse function to itertools
Raymond Hettinger added the comment: What is the use case for interspersing values? I've not run across anything like it ever before. -- assignee: - rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21414 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__
Raymond Hettinger added the comment: At first glance, this seems like a reasonable request. I leave it open for comments for a while before proceeding. -- assignee: - rhettinger components: +Library (Lib) nosy: +rhettinger type: - enhancement versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21421 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20544] Use specific asserts in operator tests
Raymond Hettinger added the comment: While this looks harmless, I seriously question whether it is an improvement. For example, how is this any better? -self.assertTrue(operator.setitem(a, 0, 2) is None) +self.assertIsNone(operator.setitem(a, 0, 2)) This error message for the first is already perfectly clear. I don't see anything that warrants the code churn. Also remember that changing tests is hazardous. We don't have tests for the tests. So, if a test gets damaged, we won't know about it. The particular patch seems fine, but the whole exercise of going through the test suite and altering the tests is a dubious. The odds of us getting ANY value out of this is vanishingly small. -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20544 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20544] Use specific asserts in operator tests
Terry J. Reedy added the comment: The generic error message for the first is 'False is not true'. Clear but useless. The error message for the second is the more specific 'representation of object) is not None'. Since the expression was supposed to evaluate to None, but did not, it would be helpful to me, at least, to know what it did evaluate to. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20544 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com