[issue28397] Faster index range checks

2016-10-11 Thread Stefan Krah
Stefan Krah added the comment: That matches my results as well: -O2 gives about the same speed, with -O3 doit() has a huge advantage. I'm not sure this is an optimization at all. -- ___ Python tracker

[issue17305] IDNA2008 encoding missing

2016-10-11 Thread Christian Heimes
Christian Heimes added the comment: I'm considering lack of IDNA 2008 a security issue for applications that perform DNS lookups and X.509 cert validation. Applications may end up connecting to the wrong machine and even validate the cert correctly. Wrong: >>> import socket >>>

[issue28397] Faster index range checks

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Raymond extracted his optimization into separate function and commented it. -- ___ Python tracker ___

[issue18233] SSLSocket.getpeercertchain()

2016-10-11 Thread Mariusz Masztalerczuk
Mariusz Masztalerczuk added the comment: Hello :) I'm not sure why patches created by christian.heimes is not merged to python, but because last patch was created in 2013, I've created a new version of this patch. What do you think about it? -- nosy: +mmasztalerczuk Added file:

[issue28397] Faster index range checks

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Unlikely this optimization have measurable affect on benchmarks. I opened this issue because this optimization already was applied to deque (issue23553), and it is easy to write a script for applying it to all code. But since there are doubts about this

[issue28397] Faster index range checks

2016-10-11 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka: "I opened this issue because this optimization already was applied to deque (issue23553)" Ah, change 1e89094998b2 written by Raymond Hettinger last year, Raymond who wrote (msg278397): "Don't change the code in the collections module. While

[issue28409] test.regrtest does not support multiple -x flags

2016-10-11 Thread STINNER Victor
STINNER Victor added the comment: Attached patch should fix the issue. I didn't know that argparse was so strict: "arg1 -v arg2" is not supported by default, see the issue #14191, whereas it works well with optparse. The patch uses parse_known_args() as a workaround, and then manually checks

[issue11429] ctypes is highly eclectic in its raw-memory support

2016-10-11 Thread Andreas Gnau
Changes by Andreas Gnau : -- nosy: +Rondom ___ Python tracker ___ ___ Python-bugs-list

[issue28397] Faster index range checks

2016-10-11 Thread Stefan Krah
Stefan Krah added the comment: In the following program, with gcc-5.3 doit() is significantly faster than doit2() in 64-bit Linux: #include int doit(int64_t index, int64_t nitems) { return index < 0 || index >= nitems; }

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: oh shidoit() i.e. return index < 0 || index >= nitems; is faster! -- ___ Python tracker ___

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: Much more conveniet way is to use unsigned variables in appropriate places. -- ___ Python tracker ___

[issue28409] test.regrtest does not support multiple -x flags

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: No, this is not a regression in argparse itself, nor in regrtest (as Xiang pointed, original example is incorrect use). But I'm not sure about the support of options after positional arguments. This is dangerous feature. I'm going to investigate this

[issue28397] Faster index range checks

2016-10-11 Thread STINNER Victor
STINNER Victor added the comment: Serhiy: "The latter form generates simpler machine code." Since this issue is an optimization, can you please provide results of Python benchmarks? Maybe run the performance benchmark suite? I just released performance 0.3 with new benchmarks and less bugs!

[issue28409] test.regrtest does not support multiple -x flags

2016-10-11 Thread R. David Murray
R. David Murray added the comment: OK, so this isn't a regression in argparse itself? I thought you meant it was, which is why I set it to release blocker. -- ___ Python tracker

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: -O2 -- the same speed too! -O3 really helps. -- ___ Python tracker ___ ___

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Christian Heimes
Changes by Christian Heimes : -- versions: +Python 2.7, Python 3.6, Python 3.7 -Python 3.4 ___ Python tracker ___

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Christian Heimes
Christian Heimes added the comment: Thanks for bringing this to my attention. I can confirm that the code is broken. Further more there are no tests for IDN for server_hostname. * server_hostname must be an IDN U-label (locälhost) * SSL handshake correctly converts and sends TLS SNI as IDN

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: $ gcc -O3 -DDOIT=doit ./zzz.c -o zzz && time ./zzz real0m1.675s user0m1.672s sys 0m0.000s $ gcc -O3 -DDOIT=doit2 ./zzz.c -o zzz && time ./zzz real0m1.657s user0m1.656s sys 0m0.000s

[issue28397] Faster index range checks

2016-10-11 Thread Stefan Krah
Stefan Krah added the comment: On 64-bit Linux there's no difference: $ ./usr/bin/gcc -O3 -o issue28397-2 issue28397-2.c $ time ./issue28397-2 0 real0m2.486s user0m2.424s sys 0m0.014s $ time ./issue28397-2 1 real0m2.433s user0m2.422s sys 0m0.008s Also, most of the

[issue28397] Faster index range checks

2016-10-11 Thread Stefan Krah
Stefan Krah added the comment: The difference in favor of doit() is even more pronounced with this loop (also sorry for the uninitialized variable, but that does not make a difference for benchmarking): = for (i = 0; i < 1; i++) { for (j = 0; j <

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: I have tested. performace differs in about of two times. gcc -O3 0.22 nanoseconds per comparison. vs 0.58 nanoseconds per comparison. Does it cost a time that we spent to discuss here ? -- nosy: +mmarkk ___ Python

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Anton Sychugov
Anton Sychugov added the comment: Yes, I misspelled, match_hostname() fails with ssl.CertificateError. -- ___ Python tracker ___

[issue28397] Faster index range checks

2016-10-11 Thread Stefan Krah
Stefan Krah added the comment: Which version is faster in your tests? -- ___ Python tracker ___ ___

[issue28397] Faster index range checks

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: In your example functions are inlined. If prohibit inlining, the second function is faster. $ gcc -O3 -o issue28397 issue28397-2.c $ time ./issue28397 0 real0m8.097s user0m7.992s sys 0m0.012s $ time ./issue28397 1 real0m5.467s user

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: Without optimisation in compiler (-O0) speed is the same. -- ___ Python tracker ___

[issue28397] Faster index range checks

2016-10-11 Thread Марк Коренберг
Марк Коренберг added the comment: $ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609 -- ___ Python tracker ___

[issue12660] test_gdb fails when installed

2016-10-11 Thread INADA Naoki
INADA Naoki added the comment: Is this issue OK to close? -- nosy: +inada.naoki ___ Python tracker ___ ___

[issue28409] test.regrtest does not support multiple -x flags

2016-10-11 Thread STINNER Victor
STINNER Victor added the comment: Xiang: "This regression is introduced in 4df2d43e995d." Sorry, my commit message is very short. I made this change because I was very annoying of getting "unknown test -m" and "unknown test test_access" when using the -m option to filter tests: ./python

[issue27923] PEP 467 -- Minor API improvements for binary sequences

2016-10-11 Thread Martin Panter
Martin Panter added the comment: For arbitrary C-contiguous buffers aka “bytes-like objects” (which are not just arrays of bytes), I think this trick relies on Issue 15944, which is only added in 3.5+. -- ___ Python tracker

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Guido van Rossum
Changes by Guido van Rossum : -- nosy: -gvanrossum ___ Python tracker ___ ___

[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2016-10-11 Thread SilentGhost
Changes by SilentGhost : -- nosy: +alexandre.vassalotti ___ Python tracker ___ ___

[issue24398] Update test_capi to use test.support.script_helper

2016-10-11 Thread Aidin Gharibnavaz
Aidin Gharibnavaz added the comment: I tested the patch locally, on my Gnu/Linux machine, and it seems fine. -- keywords: +patch Added file: http://bugs.python.org/file45060/issue24398.patch ___ Python tracker

[issue27923] PEP 467 -- Minor API improvements for binary sequences

2016-10-11 Thread Nick Coghlan
Nick Coghlan added the comment: Something else the PEP needs to be updated to cover is that in 3.5+ (and maybe even in 3.4 - I'm not sure when 'c' support landed in memoryview) you can write the following efficient bytes iterator: def iterbytes(data): return

[issue28417] va_end twice in PyUnicode_FromFormatV

2016-10-11 Thread Xiang Zhang
New submission from Xiang Zhang: vargs2 could be va_end()ed twice in PyUnicode_FromFormatV when format contains non-ascii characters. Once va_end()ed, vargs2 is undefined. So this could lead to undefined behaviour. -- components: Interpreter Core files: PyUnicode_FromFormatV.patch

[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2016-10-11 Thread Carl Witty
New submission from Carl Witty: On creation, _pickle.Pickler caches any .persistent_id() method defined by a subclass (in the pers_func field of PicklerObject). This causes a reference cycle (pickler -> bound method of pickler -> pickler), so the pickler is held in memory until the next

[issue27923] PEP 467 -- Minor API improvements for binary sequences

2016-10-11 Thread Andreas Gnau
Changes by Andreas Gnau : -- nosy: +Rondom ___ Python tracker ___ ___ Python-bugs-list

[issue27923] PEP 467 -- Minor API improvements for binary sequences

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Even in 3.3+. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2016-10-11 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka type: behavior -> resource usage versions: +Python 2.7, Python 3.6, Python 3.7 ___ Python tracker

[issue28418] Raise Deprecation warning for tokenize.generate_tokens

2016-10-11 Thread Matthias Bussonnier
New submission from Matthias Bussonnier: the Tokenize module has the following code: # An undocumented, backwards compatible, API for all the places in the standard # library that expect to be able to use tokenize with strings def generate_tokens(readline): return _tokenize(readline, None)

[issue28420] is ok

2016-10-11 Thread Vagner Clementino
Changes by Vagner Clementino : -- nosy: Vagner Clementino priority: normal severity: normal status: open title: is ok ___ Python tracker

[issue28419] List comprehension in class scope does not have access to class scope

2016-10-11 Thread David Eyk
David Eyk added the comment: Thanks for the pointer. That seems weird and arbitrary when you think of it in terms of scope, but what can you do? All the same, thanks for the quick response. :) -- ___ Python tracker

[issue28411] Eliminate PyInterpreterState.modules.

2016-10-11 Thread Eric Snow
Eric Snow added the comment: Hmm, actually _PyImport_GetModuleDict() isn't needed to solve the startup issue. It's still rather internally focused but the same could be said for PyImport_GetModuleDict(). I guess I'm still not sold on adding a new public API function for what amounts to a

[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-11 Thread Nick Coghlan
Nick Coghlan added the comment: Thanks Berker - looks good to me! Should we file a separate issue regarding the similarly vague error message from hasattr() itself? -- ___ Python tracker

[issue28420] is ok

2016-10-11 Thread Zachary Ware
Changes by Zachary Ware : -- resolution: -> not a bug stage: -> resolved ___ Python tracker ___

[issue28411] Eliminate PyInterpreterState.modules.

2016-10-11 Thread Nick Coghlan
Nick Coghlan added the comment: I just checked the docs, and it turns out I'm wrong about this being a previously public API: "There are no public members in this structure." >From https://docs.python.org/3/c-api/init.html#c.PyInterpreterState That means the only externally supported API that

[issue28420] is ok

2016-10-11 Thread Xiang Zhang
Changes by Xiang Zhang : -- status: open -> closed ___ Python tracker ___ ___

[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If run Python 3 with -bb: >>> __import__('encodings', fromlist=[b'aliases']) Traceback (most recent call last): File "", line 1, in File "", line 1000, in _handle_fromlist BytesWarning: Comparison between bytes and string -- nosy:

[issue28419] List comprehension in class scope does not have access to class scope

2016-10-11 Thread David Eyk
New submission from David Eyk: I've discovered what appears to be a scoping bug in Python 3.5.1, where the class scope is not available inside a list comprehension defined in the class scope. Attached is a simple example script, also available at the following gist:

[issue28419] List comprehension in class scope does not have access to class scope

2016-10-11 Thread R. David Murray
R. David Murray added the comment: See issue 11796, and the issue it is marked as a duplicate of, for an explanation. -- nosy: +r.david.murray resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Comprehensions in a class definition mostly cannot access

[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-11 Thread Berker Peksag
Berker Peksag added the comment: Good catch, thanks Nick. Here's a Python 3 version of the patch. I excluded Python/importlib.h from the patch to make review easier. -- components: +Interpreter Core versions: +Python 3.5, Python 3.6, Python 3.7 Added file:

[issue28411] Eliminate PyInterpreterState.modules.

2016-10-11 Thread Eric Snow
Eric Snow added the comment: What's the benefit to adding PyInterpreterState_GetModuleCache()? TBH, it should only be needed in this short period during startup when the import system hasn't been bootstrapped yet. After that code can import sys and access sys.modules from there. (For that

[issue28411] Eliminate PyInterpreterState.modules.

2016-10-11 Thread Eric Snow
Eric Snow added the comment: Meh, there really isn't any need for _PyImport_GetModuleDict(). I'll drop it. Problem solved! :) -- ___ Python tracker

[issue18844] allow weights in random.choice

2016-10-11 Thread Roundup Robot
Roundup Robot added the comment: New changeset 433cff92d565 by Raymond Hettinger in branch '3.6': Issue #18844: Fix-up examples for random.choices(). Remove over-specified test. https://hg.python.org/cpython/rev/433cff92d565 -- ___ Python tracker

[issue28393] Update encoding lookup docs wrt #27938

2016-10-11 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the patch! Do we still need to keep the last sentence? Is there any other alternatives that can be used? Perhaps the word "spellings" can be changed with "aliases" to make the sentence a little bit clearer. -- nosy: +berker.peksag stage: ->

[issue28393] Update encoding lookup docs wrt #27938

2016-10-11 Thread Ville Skyttä
Ville Skyttä added the comment: I believe (but haven't checked) that additionally, encoding names are case insensitive with respect to the fast-path behavior. But then again I also suppose that's the way it was before #27938 as well, which is why I didn't change that in this patch. But why

[issue28418] Raise Deprecation warning for tokenize.generate_tokens

2016-10-11 Thread Martin Panter
Martin Panter added the comment: There is related discussion in Issue 12486 about supporting unencoded text input. The current patch there actually already raises a warning and removes call sites from the Python library, though it does not add a doc string. -- nosy: +martin.panter

[issue28410] Add convenient C API for "raise ... from ..."

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I don't know how it is related to issue23188. Maybe solving issue23188 will make _PyErr_ChainExceptions and the function proposed in this issue redundant. Or will make them simpler. But it looks to me that issue23188 is far from the completion. --

[issue28413] unprefixed global symbol freegrammar

2016-10-11 Thread Roundup Robot
Roundup Robot added the comment: New changeset 032d807039b9 by Benjamin Peterson in branch '3.6': prefix freegrammar (closes #28413) https://hg.python.org/cpython/rev/032d807039b9 -- nosy: +python-dev resolution: -> fixed stage: needs patch -> resolved status: open -> closed

[issue28413] unprefixed global symbol freegrammar

2016-10-11 Thread Matthias Klose
New submission from Matthias Klose: changeset 103932 introduced an unprefixed global symbol freegrammar. Please make it local, or prefix it with _Py_. -- messages: 278463 nosy: benjamin.peterson, doko priority: normal severity: normal stage: needs patch status: open title: unprefixed

[issue28409] test.regrtest does not support multiple -x flags

2016-10-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Indeed, previously -x in the middle of test names worked only by accident, because it was interpreted as the name of excluded test. Now it stops positional arguments. Current behavior is explainable, but surprising. This part of argparse is not clear and

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Anton Sychugov
New submission from Anton Sychugov: In accordance with http://tools.ietf.org/html/rfc6125#section-6.4.2: "If the DNS domain name portion of a reference identifier is an internationalized domain name, then an implementation MUST convert any U-labels [IDNA-DEFS] in the domain name to A-labels

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Anton Sychugov
Changes by Anton Sychugov : -- type: -> enhancement ___ Python tracker ___ ___

[issue28415] PyUnicode_FromFromat interger format handling different from printf about zeropad

2016-10-11 Thread Xiang Zhang
New submission from Xiang Zhang: Although declared *exactly equivalent* to printf in the doc, PyUnicode_FromFormat could generate different result from printf with the same format. For example: from ctypes import pythonapi, py_object, c_int f = getattr(pythonapi, 'PyUnicode_FromFormat')

[issue28414] SSL match_hostname fails for internationalized domain names

2016-10-11 Thread Anton Sychugov
Changes by Anton Sychugov : -- assignee: -> christian.heimes components: +SSL nosy: +christian.heimes ___ Python tracker ___

[issue28384] hmac cannot be used with shake algorithms

2016-10-11 Thread Christian Heimes
Christian Heimes added the comment: It's not a bug, but indented behavior. It does not make any sense to use SHAKE with the HMAC construct. In fact it does not make sense to combine Keccak sponge or Blake2 with HMAC at all. HMAC is only necessary for old, Merkle-Damgard hashing algorithms