[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Antony Lee

New submission from Antony Lee :

Consider e.g.

In [2]: %timeit sorted([i for i in range(100)])
4.74 µs ± 24.3 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [3]: %timeit sorted(i for i in range(100))
7.05 µs ± 25.7 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [4]: %timeit sorted([i for i in range(1000)])
47.2 µs ± 1.2 µs per loop (mean ± std. dev. of 7 runs, 1 loops each)

In [5]: %timeit sorted(i for i in range(1000))
78.7 µs ± 288 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)

In [6]: %timeit sorted([i for i in range(1)])
582 µs ± 8.29 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [7]: %timeit sorted(i for i in range(1))
807 µs ± 5.92 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

It appears that sorting a generator is slower than sorting the corresponding 
list comprehension, by a ~constant factor.  Given that the former can trivially 
be converted into the latter (i.e. `sorted` could just check whether its 
argument is a generator, and, if so, convert it to a list first), it would seem 
that sorting the generator should *not* be slower than sorting a list (except 
perhaps by a small constant).

--
messages: 312780
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: sorted(generator) is slower than sorted(list-comprehension)
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32946] Speed up import from non-packages

2018-02-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

The proposed PR optimizes "from ... import ..." from non-package modules.

$ ./python -m perf timeit 'from locale import getlocale'
Unpatched:  Mean +- std dev: 811 ns +- 27 ns
Patched:Mean +- std dev: 624 ns +- 17 ns

Currently _bootstrap._handle_fromlist() is called which does nothing if the 
module is not a package, but adds an overhead of calling a Python function. The 
PR moves this check out of _handle_fromlist and avoid calling it if not needed.

--
components: Interpreter Core
messages: 312781
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Speed up import from non-packages
type: performance
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32185] SSLContext.wrap_socket sends SNI Extension when server_hostname is IP

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5644

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Stefan Behnel

Stefan Behnel  added the comment:

sorted() *does* convert its input to a list first, and only then sorts it. It 
calls PySequence_List() for that, which in turn uses list_extend(), which then 
applies the obvious optimisation of copying input lists (and tuples) directly.

What you are seeing here is probably mostly this difference:

$ python3.7 -m timeit 'list(i for i in range(100))'
5 loops, best of 5: 5.95 usec per loop
$ python3.7 -m timeit '[i for i in range(100)]'
10 loops, best of 5: 3.26 usec per loop

--
components: +Interpreter Core
nosy: +scoder
type:  -> performance
versions: +Python 3.8 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32185] SSLContext.wrap_socket sends SNI Extension when server_hostname is IP

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset e9370a47389903bb72badc95032ec84a0ebbf8cc by Christian Heimes in 
branch '3.6':
bpo-32185: Don't send IP in SNI TLS extension (#5865)
https://github.com/python/cpython/commit/e9370a47389903bb72badc95032ec84a0ebbf8cc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25404] ssl.SSLcontext.load_dh_params() does not handle unicode filenames properly

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 6e8f395001b026daea047cf225dcca5a973ae824 by Christian Heimes in 
branch '2.7':
bpo-25404: SSLContext.load_dh_params() non-ASCII path (GH-3459)
https://github.com/python/cpython/commit/6e8f395001b026daea047cf225dcca5a973ae824


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25404] ssl.SSLcontext.load_dh_params() does not handle unicode filenames properly

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31809] ssl module unnecessarily pins the client curve when using ECDH

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset b7b9225831a729bff84eb7c43bad138416b994fe by Christian Heimes in 
branch 'master':
bpo-31809: test secp ECDH curves (#4036)
https://github.com/python/cpython/commit/b7b9225831a729bff84eb7c43bad138416b994fe


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31809] ssl module unnecessarily pins the client curve when using ECDH

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5645

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32946] Speed up import from non-packages

2018-02-25 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +5646
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32185] SSLContext.wrap_socket sends SNI Extension when server_hostname is IP

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset a5c9112300ecd492ed6cc9759dc8028766401f61 by Christian Heimes 
(Miss Islington (bot)) in branch '2.7':
[2.7] bpo-32185: Don't send IP in SNI TLS extension (GH-5865) (#5871)
https://github.com/python/cpython/commit/a5c9112300ecd492ed6cc9759dc8028766401f61


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32185] SSLContext.wrap_socket sends SNI Extension when server_hostname is IP

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:

The issue has been fixed in 2.7, 3.6-3.8 for OpenSSL >= 1.0.2 or platforms with 
inet_pton. I didn't bother to fix platforms without inet_pton since OpenSSL 
1.0.1 and earlier are no longer support any way.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 48707a1baf4fd553fbc4516d9080cb3968af21aa by Christian Heimes in 
branch '3.6':
[3.6] bpo-30622: Improve NPN support detection (GH-5859) (#5861)
https://github.com/python/cpython/commit/48707a1baf4fd553fbc4516d9080cb3968af21aa


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 3d87f4cf9c19da9fe8ae8f91f5bb86e642b74a50 by Christian Heimes in 
branch '2.7':
[2.7] bpo-30622: Improve NPN support detection (GH-5859) (#5863)
https://github.com/python/cpython/commit/3d87f4cf9c19da9fe8ae8f91f5bb86e642b74a50


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5647

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 5bb9692575f10f4a7c7f1c2c0c70956baf6d5c23 by Christian Heimes in 
branch 'master':
bpo-32647: Link ctypes extension with libdl. (#5550)
https://github.com/python/cpython/commit/5bb9692575f10f4a7c7f1c2c0c70956baf6d5c23


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5648

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Antony Lee

Antony Lee  added the comment:

Feel free to close the issue if that's not the forum for this discussion, but 
I'm still baffled by what's happening.

In the example that you give, the first case needs to look up the `list` global 
and that callable (which happens to be the `list` type) needs to figure out 
what to do with generator passed in.  Indeed, we can compare

In [22]: dis.dis(compile("[i for i in [1, 2]]", "", "single"))
  1   0 LOAD_CONST   0 ( at 
0x7f2d3237ec00, file "", line 1>)
  2 LOAD_CONST   1 ('')
  4 MAKE_FUNCTION0
  6 LOAD_CONST   5 ((1, 2))
  8 GET_ITER
 10 CALL_FUNCTION1
 12 PRINT_EXPR
 14 LOAD_CONST   4 (None)
 16 RETURN_VALUE

In [23]: dis.dis(compile("list(i for i in [1, 2])", "", "single"))
  1   0 LOAD_NAME0 (list)
  2 LOAD_CONST   0 ( at 
0x7f2d32392150, file "", line 1>)
  4 LOAD_CONST   1 ('')
  6 MAKE_FUNCTION0
  8 LOAD_CONST   5 ((1, 2))
 10 GET_ITER
 12 CALL_FUNCTION1
 14 CALL_FUNCTION1
 16 PRINT_EXPR
 18 LOAD_CONST   4 (None)
 20 RETURN_VALUE

Note how the latter has an extra function call (to `list`).

In the example I gave, however:

In [24]: dis.dis(compile("sorted([i for i in [1, 2]])", "", 
"single"))
1   0 LOAD_NAME0 (sorted)
2 LOAD_CONST   0 ( at 
0x7f2d3231eb70, file "", line 1>)
4 LOAD_CONST   1 ('')
6 MAKE_FUNCTION0
8 LOAD_CONST   5 ((1, 2))
10 GET_ITER
12 CALL_FUNCTION1
14 CALL_FUNCTION1
16 PRINT_EXPR
18 LOAD_CONST   4 (None)
20 RETURN_VALUE

In [25]: dis.dis(compile("sorted(i for i in [1, 2])", "", "single"))
1   0 LOAD_NAME0 (sorted)
2 LOAD_CONST   0 ( at 
0x7f2d32328930, file "", line 1>)
4 LOAD_CONST   1 ('')
6 MAKE_FUNCTION0
8 LOAD_CONST   5 ((1, 2))
10 GET_ITER
12 CALL_FUNCTION1
14 CALL_FUNCTION1
16 PRINT_EXPR
18 LOAD_CONST   4 (None)
20 RETURN_VALUE

so both cases are much more similar -- superficially, at least.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32932] better error message when __all__ contains non-str objects

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

On other hand, adding checks in Python code will add a slowdown. See issue32946 
which moves in contrary direction.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Stefan Behnel

Stefan Behnel  added the comment:

The constant function call overhead doesn't make a big difference:

$ /opt/python3.7-opt/bin/python3 -m timeit 'list(i for i in range(1000))'
5000 loops, best of 5: 55 usec per loop
$ /opt/python3.7-opt/bin/python3 -m timeit '[i for i in range(1000)]'
1 loops, best of 5: 30.7 usec per loop

The difference is that comprehensions are generally more efficient than 
generators, simply because they are more specialised. When a generator is 
created, it does not know whether it will be passed into list() to quickly 
unpack it into a list, or into some complex machinery that just requests one 
value per year, or only one value at all and then throws it away.

I searched a bit, but couldn't find a ticket about the performance difference 
above, although I'm sure there must be one. So I'll leave this open for now, 
assuming that there might still be something to improve here.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31809] ssl module unnecessarily pins the client curve when using ECDH

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset ff7528f089b60f8372c658f3bc3b14b059114da9 by Christian Heimes 
(Miss Islington (bot)) in branch '3.7':
[3.7] bpo-31809: test secp ECDH curves (GH-4036) (#5872)
https://github.com/python/cpython/commit/ff7528f089b60f8372c658f3bc3b14b059114da9


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
pull_requests: +5649

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
pull_requests: +5650

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12345] Add math.tau

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
pull_requests: +5651

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12345] Add math.tau

2018-02-25 Thread Mark Dickinson

Change by Mark Dickinson :


--
pull_requests:  -5651

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

I think the difficulty here is that your perspective is backwards. It isn't 
that sorting a generator is *slower*, it is that sorting a list is *faster*, 
because there is more information available with a list and so the interpreter 
can take a short-cut.

With a generator or iterator, the interpreter doesn't know how many items will 
be in the finished collection, and so it has to build the list in stages as 
needed, growing it when it runs out of room, and possibly shrinking it if it 
grows too big. This takes time.

But with a list or other sequence with a known length, the interpreter can 
allocate the right number of items up front, and avoid growing or shrinking the 
new list. I believe that this is the time saving you are seeing.

So I don't think this is a bug, and I don't think there's any room to optimize 
the generator comprehension case. Unless somebody who knows more about the 
interpreter internals than I do speaks up to say there is a way to optimize 
this case, I think there's nothing that can be done.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32940] IDLE: pyparse - simplify StringTranslatePseudoMapping

2018-02-25 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

To me, it is plausible but not slam-dunk obvious that preloading ascii to 'x' 
mappings will make ascii lookup faster.

On #21765, where the pyparse special translation was a side-issue, Tal Einat 
claimed that the unpublished regex he tried was 100x slower.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17288] cannot jump from a return after setting f_lineno

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Do you mind to create a PR from your patch Xavier? The code of the f_lineno 
setter was changed in the master branch, so that it is better to create a PR 
for the 3.7 branch and later port it to master.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Antony Lee

Antony Lee  added the comment:

> But with a list or other sequence with a known length, the interpreter can 
> allocate the right number of items up front, and avoid growing or shrinking 
> the new list. I believe that this is the time saving you are seeing.

But certainly when the list comprehension is executed the interpreter also 
needs to pay that cost?  (It cannot know a priori that `[x for x in 
range(100)]` will have 100 elements, as `range` may have been shadowed at that 
point.)

Yes, the price is not paid when running `sorted` itself, but it should be paid 
when creating the list from the comprehension?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32940] IDLE: pyparse - simplify StringTranslatePseudoMapping

2018-02-25 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

A similar regular expression version was mentioned on issue21765 and I had run 
some tests on it yesterday to verify.  On my system, it ran at a factor of 10x 
slower, so if the translate finished in 0.003, the regex took 0.03.  This was 
consistent for me, regardless of how big I made the document.

The reason for not using a defauldict was to keep the 'x' mappings out of the 
dictionary so that it wouldn't grow and take up space.  Although, I did realize 
yesterday that it wasn't really boundless because most values in source code 
would be ASCII.  Running both the version the doesn't add the 'x' mappings and 
the `fromkeys`, there doesn't seem to be much of a difference in time when 
processing the doc.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Created a PR based on the discussion and not the original patch.

--
nosy: +csabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +patch
pull_requests: +5652
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Stefan Behnel

Stefan Behnel  added the comment:

> as `range` may have been shadowed at that point

No, range() has in fact already been executed at that point. And it returned an 
iterable that knows its length (search for "LengthHint" in the CPython sources).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12345] Add math.tau

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
pull_requests: +5653

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 4bb9b9aea04b1a96632da1b30a58fb31cbe6ec92 by Christian Heimes in 
branch '2.7':
[2.7] bpo-32647: Link ctypes extension with libdl. (GH-5550) (#5877)
https://github.com/python/cpython/commit/4bb9b9aea04b1a96632da1b30a58fb31cbe6ec92


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5654

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 29eab55309b9f78b79074d26db16a44e7841c639 by Christian Heimes in 
branch 'master':
bpo-30622: Fix NPN for OpenSSL 1.1.1-pre1 (#5876)
https://github.com/python/cpython/commit/29eab55309b9f78b79074d26db16a44e7841c639


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32933] mock_open does not support iteration around text files.

2018-02-25 Thread Anthony Flury

Change by Anthony Flury :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32947] Support OpenSSL 1.1.1

2018-02-25 Thread Christian Heimes

New submission from Christian Heimes :

I'm using this ticket as an epos to track commits and required changes for 
OpenSSL 1.1.1 and TLS 1.3. Fixes need to be backported to 2.7 and 3.6 to 3.8. 
We might have to consider backports to 3.4 and 3.5, too.

If all goes to plan, OpenSSL 1.1.1 final is scheduled for 8th May 2018, 
https://www.openssl.org/policies/releasestrat.html . It will contain support 
for TLS 1.3. Python should either support TLS 1.3 by then or disable TLS 1.3 by 
default.

Fixes:

* #20995 added TLS 1.3 cipher suite support
* #29136 added OP_NO_TLSv1_3
* #30622 fixes NPN guard for OpenSSL 1.1.1

Issues:

* A new option OP_ENABLE_MIDDLEBOX_COMPAT is enabled by default. We need to 
expose the flag to make test pass.
* TLS 1.3 has changed session handling. The current session code cannot handle 
TLS 1.3 session resumption.
* Threaded echo server and asynchat based tests are failing with TLS 1.3. I 
haven't analyzed the issue properly. It looks like the server thread dies when 
a handshake error occurs.

--
assignee: christian.heimes
components: SSL
messages: 312804
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: Support OpenSSL 1.1.1
type: enhancement
versions: Python 2.7, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32947] Support OpenSSL 1.1.1

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
keywords: +patch
pull_requests: +5655
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 192bff4e2d196b8933829923ca1db77d8dee67e2 by Christian Heimes 
(Miss Islington (bot)) in branch '3.6':
[3.6] bpo-32647: Link ctypes extension with libdl. (GH-5550) (#5875)
https://github.com/python/cpython/commit/192bff4e2d196b8933829923ca1db77d8dee67e2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32647] Undefined references when compiling ctypes on binutils 2.29.1 with gcc -Wl, -z, undefs (Fedora 28)

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 4cb373359d5ff29b222b10207516d294f3a54ad8 by Christian Heimes 
(Miss Islington (bot)) in branch '3.7':
[3.7] bpo-32647: Link ctypes extension with libdl. (GH-5550) (#5874)
https://github.com/python/cpython/commit/4cb373359d5ff29b222b10207516d294f3a54ad8


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes via Python-bugs-list

Change by Christian Heimes :


--
pull_requests: +5656

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
pull_requests: +5657

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 961774184eb950e2547ab0d42653439adc735924 by Christian Heimes 
(Miss Islington (bot)) in branch '3.7':
[3.7] bpo-30622: Fix NPN for OpenSSL 1.1.1-pre1 (GH-5876) (#5880)
https://github.com/python/cpython/commit/961774184eb950e2547ab0d42653439adc735924


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17288] cannot jump from a return after setting f_lineno

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Example in msg183254 doesn't crash Python 3.8.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28883] Python 3.5.2 crashers (from PyPy)

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

C5 is fixed in 3.8 by issue17611.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32948] clang compiler warnings on Travis

2018-02-25 Thread Christian Heimes

New submission from Christian Heimes :

I'm seeing a bunch of compile errors on 2.7 branch, 
https://travis-ci.org/python/cpython/jobs/345906584


/home/travis/build/python/cpython/Modules/_heapqmodule.c:600:21: warning: 
illegal character encoding in string literal [-Winvalid-source-encoding]
[explanation by Franois Pinard]\n\
^~~~
Include/Python.h:174:60: note: expanded from macro 'PyDoc_STRVAR'
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
   ^
Include/Python.h:176:24: note: expanded from macro 'PyDoc_STR'
#define PyDoc_STR(str) str
   ^
1 warning generated.

clang -pthread -fno-strict-aliasing -OPT:Olimit=0 -g -O2 -g -O0 -Wall 
-Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -c 
./Modules/pwdmodule.c -o Modules/pwdmodule.o
./Modules/posixmodule.c:363:13: warning: comparison of constant 
9223372036854775807 with expression of type 'uid_t' (aka 'unsigned int') is 
always true [-Wtautological-constant-out-of-range-compare]
if (uid <= LONG_MAX)
~~~ ^  
./Modules/posixmodule.c:371:13: warning: comparison of constant 
9223372036854775807 with expression of type 'gid_t' (aka 'unsigned int') is 
always true [-Wtautological-constant-out-of-range-compare]
if (gid <= LONG_MAX)
~~~ ^  
clang -pthread -fno-strict-aliasing -OPT:Olimit=0 -g -O2 -g -O0 -Wall 
-Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -c 
./Modules/_sre.c -o Modules/_sre.o
clang -pthread -fno-strict-aliasing -OPT:Olimit=0 -g -O2 -g -O0 -Wall 
-Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -c 
./Modules/_codecsmodule.c -o Modules/_codecsmodule.o
./Modules/pwdmodule.c:115:17: warning: comparison of unsigned expression < 0 is 
always false [-Wtautological-compare]
if (uid < 0)
~~~ ^ ~
1 warning generated.

/home/travis/build/python/cpython/Modules/grpmodule.c:102:17: warning: 
comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (gid < 0)
~~~ ^ ~
1 warning generated.

/cpython/Modules/nismodule.c -o 
build/temp.linux-x86_64-2.7-pydebug/home/travis/build/python/cpython/Modules/nismodule.o
/home/travis/build/python/cpython/Modules/nismodule.c:404:15: warning: 
  explicitly assigning value of variable of type 'nismaplist *' (aka
  'struct nismaplist *') to itself [-Wself-assign]
for (maps = maps; maps; maps = maps->next) {
  ^ 
1 warning generated.

/cpython/Modules/_cursesmodule.c -o 
build/temp.linux-x86_64-2.7-pydebug/home/travis/build/python/cpython/Modules/_cursesmodule.o
/home/travis/build/python/cpython/Modules/_cursesmodule.c:1082:15: warning: 
  implicit conversion from 'chtype' (aka 'unsigned long') to 'int' changes
  value from 18446744073709551615 to -1 [-Wconstant-conversion]
rtn = mvwinch(self->win,y,x);
~ ^~
/usr/include/curses.h:1247:58: note: expanded from macro 'mvwinch'
  ...(wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
^
/usr/include/curses.h:222:34: note: expanded from macro 'NCURSES_CAST'
#define NCURSES_CAST(type,value) (type)(value)
 ^
1 warning generated.

--
components: Extension Modules
messages: 312810
nosy: christian.heimes
priority: low
severity: normal
stage: needs patch
status: open
title: clang compiler warnings on Travis
type: compile error
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset a79591cfb81dde65bb2f891d62de0161c23a4ff4 by Christian Heimes in 
branch '3.6':
[3.6] bpo-30622: Fix NPN for OpenSSL 1.1.1-pre1 (GH-5876) (#5881)
https://github.com/python/cpython/commit/a79591cfb81dde65bb2f891d62de0161c23a4ff4


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset df1732a4734190fefc8814687895fc1168716c37 by Christian Heimes in 
branch '2.7':
[2.7] bpo-30622: Fix NPN for OpenSSL 1.1.1-pre1 (GH-5876) (#5882)
https://github.com/python/cpython/commit/df1732a4734190fefc8814687895fc1168716c37


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32949] Simplify "with"-related opcodes

2018-02-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

There are some issues with "with"-related opcodes.

All other opcodes has constant stack effect for particular control flow. For 
example FOR_ITER always has the stack effect 1 if not jump (pushes the next 
item) and -1 if jumps (pops the iterator). The only exceptions are 
WITH_CLEANUP_START which pushes 1 or 2 values depending on TOS, and 
WITH_CLEANUP_FINISH which pops 2 or 3 values depending on values pushed by 
preceding WITH_CLEANUP_START. This breaks consistency and may make debugging 
harder.

WITH_CLEANUP_START duplicates a one of values on the stack without good 
reasons. Even the comment in the initial commit exposed uncertainty in this.

The proposed PR simplifies WITH_CLEANUP_START and WITH_CLEANUP_FINISH. They 
will be now executed only when the exception is raised. In normal case they 
will be replaced with calling a  function `__exit__(None, None, None)`.

LOAD_CONST   0 ((None, None, None))
CALL_FUNCTION_EX 0
POP_TOP

WITH_CLEANUP_FINISH will be merged with the following END_FINALLY.

This PR is inspired by PR 5112 by Mark Shannon, but Mark goes further.

In addition to simplifying the implementation and the mental model, the PR adds 
a tiny bit of performance gain.

$ ./python -m perf timeit -s 'class CM:' -s '  def __enter__(s): pass' -s '  
def __exit__(*args): pass' -s 'cm = CM()' -- 'with cm: pass'

Unpatched:  Mean +- std dev: 227 ns +- 6 ns
Patched:Mean +- std dev: 205 ns +- 10 ns

--
components: Interpreter Core
messages: 312813
nosy: Mark.Shannon, benjamin.peterson, pitrou, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Simplify "with"-related opcodes
type: performance
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32949] Simplify "with"-related opcodes

2018-02-25 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +5658
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32017] profile.Profile() has no method enable()

2018-02-25 Thread bbayles

bbayles  added the comment:

I'm afraid that profile.Profile and cProfile.Profile behave pretty differently, 
and there's not a good way to bring the methods from the C version to the 
Python version.

The example at [1] shows a cProfile.Profile object being instantiated and 
enabled. At this point the profiler is tracing execution - until the disable() 
method is called, any activity is recorded.

profile.Profile doesn't work this way. Creating a profile.Profile object 
doesn't cause activity to be recorded. It doesn't do anything until you call 
one of its run* methods.

This is because the C version uses PyEval_SetProfile ([2]) to take advantage of 
CPython's "low-level support for attaching profiling and execution tracing 
facilities" ([3]). I don't think we can do that from the Python version.

There is already a precedent for showing differences between cProfile.Profile 
and profile.Profile in the existing docs - see [4].


[1] https://docs.python.org/3/library/profile.html#profile.Profile
[2] 
https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Modules/_lsprof.c#L693
[3] https://docs.python.org/3/c-api/init.html#profiling-and-tracing
[4] https://docs.python.org/3/library/profile.html#using-a-custom-timer

--
nosy: +bbayles

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17611] Move unwinding of stack for "pseudo exceptions" from interpreter to compiler.

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Finally it is merged, and seems successfully. Thank you all involved, and first 
at all Mark, the original author.

This unblocked further changes, issue32489 and issue32949. And we can try 
implement other ideas.

Changes in the f_lineno setter fixed crashes in issue17288 and issue28883. But 
while writing tests for it I found other crashers, will open new issues soon.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32950] profiling python gc

2018-02-25 Thread Luavis

New submission from 강성일 (Luavis) :

There is way to logging python garbage collection event. but no way to 
profiling it.

--
messages: 312816
nosy: 강성일 (Luavis)
priority: normal
severity: normal
status: open
title: profiling python gc
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13607] Move generator specific sections out of ceval.

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

The WHY_* codes are gone in 3.8 (see issue17611). Exception state was moved 
from frame to generator in 3.7 (see issue25612).

Can some parts of the patch be applied to the current code? Or it is completely 
outdated?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13607] Move generator specific sections out of ceval.

2018-02-25 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32017] profile.Profile() has no method enable()

2018-02-25 Thread bbayles

Change by bbayles :


--
keywords: +patch
pull_requests: +5659
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32017] profile.Profile() has no method enable()

2018-02-25 Thread bbayles

bbayles  added the comment:

I've made a pull request that clarifies things in the docs.

As csabella notes, there are some more differences that could be pointed out. 
The 'subcalls' and 'builtins' arguments could be explained as well.

Nonetheless, I think the PR does fix some definitely incorrect aspects of the 
existing documentation and is at least an improvement.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13897] Move fields relevant to sys.exc_info out of frame into generator/threadstate

2018-02-25 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13897] Move fields relevant to sys.exc_info out of frame into generator/threadstate

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Aren't they were moved in issue25612? Is there something that should be done in 
this issue?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28124] Rework SSL module documentation

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
keywords: +patch
pull_requests: +5660
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32759] multiprocessing.Array do not release shared memory

2018-02-25 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32622] Implement loop.sendfile

2018-02-25 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset a19fb3c6aaa7632410d1d9dcb395d7101d124da4 by Andrew Svetlov in 
branch 'master':
bpo-32622: Native sendfile on windows (#5565)
https://github.com/python/cpython/commit/a19fb3c6aaa7632410d1d9dcb395d7101d124da4


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32622] Implement loop.sendfile

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5661

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13790] In str.format an incorrect error message for list, tuple, dict, set

2018-02-25 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

>From the examples in msg220401, issue28385 changed it to print the object type 
>in the message. 

>>> format([], 'd')
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported format string passed to list.__format__
>>> format((), 'd')
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported format string passed to tuple.__format__


Would the change left on this issue be to create a PR for Terry's documetation 
patch?

Thanks!

--
nosy: +csabella
versions: +Python 3.6, Python 3.7, Python 3.8 -Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32622] Implement loop.sendfile

2018-02-25 Thread miss-islington

miss-islington  added the comment:


New changeset 632c1cb57176d268d65a9fd7b00582f32e0884ee by Miss Islington (bot) 
in branch '3.7':
bpo-32622: Native sendfile on windows (GH-5565)
https://github.com/python/cpython/commit/632c1cb57176d268d65a9fd7b00582f32e0884ee


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12345] Add math.tau

2018-02-25 Thread Guido van Rossum

Change by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32951] Prohibit direct instantiation of SSLSocket and SSLObject

2018-02-25 Thread Christian Heimes

New submission from Christian Heimes :

The constructors of SSLObject and SSLSocket were never documented, tested, or 
meant to be used directly. Instead users were suppose to use ssl.wrap_socket or 
an SSLContext object. The ssl.wrap_socket() function and direct instantiation 
of SSLSocket has multiple issues. From my mail "No hostname matching with 
ssl.wrap_socket() and SSLSocket() constructor" to PSRT:

The ssl module has three ways to create a
SSLSocket object:

1) ssl.wrap_socket() [1]
2) ssl.SSLSocket() can be instantiated directly without a context [2]
3) SSLContext.wrap_socket() [3]

Variant (1) and (2) are old APIs with insecure default settings.

Variant (3) is the new and preferred way. With
ssl.create_default_context() or ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
the socket is configured securely with hostname matching and cert
validation enabled.


While Martin Panter was reviewing my documentation improvements for the
ssl module, he pointed out an issue,
https://github.com/python/cpython/pull/3530#discussion_r170407478 .
ssl.wrap_socket() and ssl.SSLSocket() default to CERT_NONE but
PROTOCOL_TLS_CLIENT is documented to set CERT_REQUIRED. After a closer
look, it turned out that the code is robust and refuses to accept
PROTOCOL_TLS_CLIENT + default values with "Cannot set verify_mode to
CERT_NONE when check_hostname is enabled.". I consider the behavior a
feature.


However ssl.SSLSocket() constructor and ssl.wrap_socket() have more
fundamental security issues. I haven't looked at the old legacy APIs in
a while and only concentrated on SSLContext. To my surprise both APIs do
NOT perform or allow hostname matching. The wrap_socket() function does
not even take a server_hostname argument, so it doesn't send a SNI TLS
extension either. These bad default settings can lead to suprising
security bugs in 3rd party code. This example doesn't fail although the
hostname doesn't match the certificate:

---
import socket
import ssl

cafile = ssl.get_default_verify_paths().cafile

with socket.socket() as sock:
ssock = ssl.SSLSocket(
sock,
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=cafile,
server_hostname='www.python.org'
)
ssock.connect(('www.evil.com', 443))
---


I don't see a way to fix the issue in a secure way while keeping
backwards compatibility. We could either modify the default behavior of
ssl.wrap_socket() and SSLSocket() constructor, or drop both features
completely. Either way it's going to break software that uses them.
Since I like to get rid of variants (1) and (2), I would favor to remove
them in favor of SSLContext.wrap_socket(). At least we should implement
my documentation bug 28124 [4] and make ssl.wrap_socket() less
prominent. I'd appreciate any assistance.

By the way, SSLObject is sane because it always goes through
SSLContext.wrap_bio(). Thanks Benjamin!

Regards,
Christian


[1] https://docs.python.org/3/library/ssl.html#ssl.wrap_socket
[2] https://docs.python.org/3/library/ssl.html#ssl.SSLSocket
[3] https://docs.python.org/3/library/ssl.html#ssl.SSLContext.wrap_socket
[4] https://bugs.python.org/issue28124

--
assignee: christian.heimes
components: SSL
messages: 312823
nosy: alex, christian.heimes, dstufft, janssen, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: Prohibit direct instantiation of SSLSocket and SSLObject
type: behavior
versions: Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32951] Prohibit direct instantiation of SSLSocket and SSLObject

2018-02-25 Thread Christian Heimes

Christian Heimes  added the comment:

Antoine Pitrou replied:

The ssl.SSLSocket constructor was never meant to be called by user
code directly (and I don't think we document it as such).  Anyone doing
this is asking for trouble (including compatibility breakage as we
change the constructor signature).

ssl.wrap_socket() is essentially a legacy API.

I would suggest the following measures :

- Deprecate ssl.wrap_socket() and slate it to be removed around 3.8 or
3.9.  SSLContext is now is any recent 2.7 or 3.x version, so the
compatibility argument doesn't hold anymore.

- Severely de-emphasize ssl.wrap_socket() in the documentation (relegate
it in a "legacy API" section at the end), and put a warning that it's
insecure.


---
Alex Gaynor replied:

If SSLSocket.__init__ is meant to be private and not called by users,
perhaps we could clean up the API and remove all the legacy arguments it
takes, bring it down to just taking a context?

It'd break anyone who was relying on it, but they weren't supposed to be
relying on it in the first place... (Is it documented even?)

---

I have implemented Antoine's second proposal in #28124.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32951] Prohibit direct instantiation of SSLSocket and SSLObject

2018-02-25 Thread Christian Heimes

Change by Christian Heimes :


--
keywords: +patch
pull_requests: +5662
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

2018-02-25 Thread Eric V. Smith

Eric V. Smith  added the comment:

Here's the simplest way I can describe this, and it's also the table used 
inside the code.  The column "has-explicit-hash?" is trying to answer the 
question "is there a __hash__ function defined in this class?". It is set to 
False if either __hash__ is missing, or if __hash__ is None and there's an 
__eq__ function. I'm assuming that the __hash__ is implicit in the latter case.

# Decide if/how we're going to create a hash function.  Key is
#  (unsafe_hash, eq, frozen, does-hash-exist).  Value is the action to
#  take.
# Actions:
#  '':  Do nothing.
#  'none':  Set __hash__ to None.
#  'add':   Always add a generated __hash__function.
#  'exception': Raise an exception.
#
#+-- unsafe_hash?
#|  +--- eq?
#|  |  + frozen?
#|  |  |  +  has-explicit-hash?
#|  |  |  |
#|  |  |  |+---  action
#|  |  |  ||
#v  v  v  vv
_hash_action = {(False, False, False, False): (''),
(False, False, False, True ): (''),
(False, False, True,  False): (''),
(False, False, True,  True ): (''),
(False, True,  False, False): ('none'),
(False, True,  False, True ): (''),
(False, True,  True,  False): ('add'),
(False, True,  True,  True ): (''),
(True,  False, False, False): ('add'),
(True,  False, False, True ): ('exception'),
(True,  False, True,  False): ('add'),
(True,  False, True,  True ): ('exception'),
(True,  True,  False, False): ('add'),
(True,  True,  False, True ): ('exception'),
(True,  True,  True,  False): ('add'),
(True,  True,  True,  True ): ('exception'),
}

PR will be ready as soon as I clean a few things up.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32945] sorted(generator) is slower than sorted(list-comprehension)

2018-02-25 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

[Antony Lee]
> so both cases are much more similar -- superficially, at least.

Try disassembling the inner code object as well -- that is where the work gets 
done and the list comprehension can take advantage of the LIST_APPEND opcode 
(rather than passing data to list_extend through an iterator which has more 
overhead).

[Stefan Behnel]
> The difference is that comprehensions are generally more efficient than 
> generators, simply because they are more specialised.

Yes, that is most succinct description of why would expect a difference.

[Steven D'Aprano]
> So I don't think this is a bug, and I don't think there's any room to 
> optimize the generator comprehension case.

I concur.

[Antony Lee]
> Feel free to close the issue if that's not the forum for this discussion, but 
> I'm still baffled by what's happening.

Yes, this discussion is more suited to a StackOverflow entry where people 
commonly ask about why Python behaves as it does.  The bug tracker is more 
suited to known regressions or provable optimizations.  (One forum is for "I'm 
baffled" and the other is for "I have an improvement").

Marking this a closed.  If some demonstrable optimization is found, feel free 
to reopen.

--
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

2018-02-25 Thread Guido van Rossum

Guido van Rossum  added the comment:

I don't know if I'm unique, but I find such a table with 4 Boolean keys
hard to understand. I'd rather see it written up as a series of nested 'if'
statements.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32856] Optimize the `for y in [x]` idiom in comprehensions

2018-02-25 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
priority: normal -> low

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32925] AST optimizer: Change a list into tuple in iterations and containment tests

2018-02-25 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

The direct inspiration of this optimization was your note that similar 
optimization was implemented in Python.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

2018-02-25 Thread Eric V. Smith

Eric V. Smith  added the comment:

if unsafe_hash:
# If there's already a __hash__, raise TypeError, otherwise add 
__hash__.
if has_explicit_hash:
hash_action = 'exception'
else:
hash_action = 'add'
else:
# unsafe_hash is False (the default).
if has_explicit_hash:
# There's already a __hash__, don't overwrite it.
hash_action = ''
else:
if eq and frozen:
# It's frozen and we added __eq__, generate __hash__.
hash_action = 'add'
elif eq and not frozen:
# It's not frozen but has __eq__, make it unhashable.
#  This is the default if no params to @dataclass.
hash_action = 'none'
else:
# There's no __eq__, use the base class __hash__.
hash_action = ''

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32880] IDLE: Fix and update and cleanup pyparse

2018-02-25 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Looking at the creation of the instances of pyparse.PyParse() and 
hyperparser.HyperParser(), I was a little surprised that they (the instances) 
are local variables to the methods and aren't instance variables.  Since they 
are called fairly often, wouldn't it be more efficient to use an instance 
variable (for example self.hp in calltips instead of hp) and update the 
attributes when something like open_calltips() is executed?  Maybe the overhead 
of creating a class is neglible compared to the storage of not destroying it 
every time?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31355] Remove Travis CI macOS job: rely on buildbots

2018-02-25 Thread Brett Cannon

Brett Cannon  added the comment:

Awesome, thanks for taking the time to verify all of that! And I agree with 
your logic to not bother backporting.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32932] better error message when __all__ contains non-str objects

2018-02-25 Thread Brett Cannon

Brett Cannon  added the comment:

This is only for `import *`, though, right? So I would argue you're already 
tossing import perf out the window if you're willing to pollute your namespace 
like that.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

2018-02-25 Thread Eric V. Smith

Change by Eric V. Smith :


--
keywords: +patch
pull_requests: +5663
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread Mariatta Wijaya

Mariatta Wijaya  added the comment:

> PR 4041 looks good to me. Mariatta, do you have time to look at Mario's patch?

Sorry I just saw this now, months later.
Looks good to me. I can merge and backport once the CI passed.
Thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

2018-02-25 Thread Eric V. Smith

Eric V. Smith  added the comment:

I've been focused on getting the code fix in for the next beta release on 
2018-02-26, and leaving the possible parameter name change for later. I don't 
feel strongly about the parameter name. Right now it's unsafe_hash, per Guido's 
original proposal.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread Mariatta Wijaya

Mariatta Wijaya  added the comment:


New changeset 84c4b0cc67ceb4b70842b78c718b6e8214874d6a by Mariatta (Cheryl 
Sabella) in branch 'master':
bpo-25059: Clarify the print separator usage in tutorial (GH-5879)
https://github.com/python/cpython/commit/84c4b0cc67ceb4b70842b78c718b6e8214874d6a


--
nosy: +Mariatta

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5664

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32394] socket lib beahavior change in 3.6.4

2018-02-25 Thread Ned Deily

Ned Deily  added the comment:

What's the status of this issue?  3.7.0b2 is tagging in 48 hours or so and 
3.6.5rc1 is in less than 2 weeks.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5665

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32604] Expose the subinterpreters C-API in Python for testing use.

2018-02-25 Thread Ned Deily

Ned Deily  added the comment:

What's the status of this issue?  3.7.0b2 is tagging in 48 hours or so.

--
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread Mariatta Wijaya

Mariatta Wijaya  added the comment:


New changeset fbee88244e8921afdb29fde51a9a010a8ae18277 by Mariatta (Mario 
Corchero) in branch 'master':
bpo-31454: Include information about "import X as Y" in Modules tutorial 
(GH-4041)
https://github.com/python/cpython/commit/fbee88244e8921afdb29fde51a9a010a8ae18277


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32872] backport of #32305 causes regressions in various packages

2018-02-25 Thread Ned Deily

Ned Deily  added the comment:

OK, I agree with Brett and Nick.  Barry, are you OK with reverting this change 
for 3.6?  If so, can you do the honors?

--
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5666

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5667

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread miss-islington

miss-islington  added the comment:


New changeset ddf2485103c1e56ba4f290641247dfa07fcbe7f3 by Miss Islington (bot) 
in branch '3.7':
bpo-25059: Clarify the print separator usage in tutorial (GH-5879)
https://github.com/python/cpython/commit/ddf2485103c1e56ba4f290641247dfa07fcbe7f3


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13790] In str.format an incorrect error message for list, tuple, dict, set

2018-02-25 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

In msg151730, R. David Murry said "Terry's [first] patch with the ("{}") 
removed should be committed, though."
In msg151738, Eric V. Smith said "I agree with your comment about Terry's 
patch."

My second patch removed "{}" but also made more text changes, explained in 
msg151757.  Someone should re-review

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5668

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread Mariatta Wijaya

Mariatta Wijaya  added the comment:

Thanks everyone. I've merged Marios's PR. The backport PRs have started and 
will automerge.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25059] Mistake in input-output tutorial regarding print() seperator

2018-02-25 Thread miss-islington

miss-islington  added the comment:


New changeset b9678d3aa156996947655ed66b554f6307b29546 by Miss Islington (bot) 
in branch '3.6':
bpo-25059: Clarify the print separator usage in tutorial (GH-5879)
https://github.com/python/cpython/commit/b9678d3aa156996947655ed66b554f6307b29546


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32872] backport of #32305 causes regressions in various packages

2018-02-25 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

I'd personally prefer to keep the fix (I ran into some problems w/3.6), but 
I'll defer to the RM.  I'll revert the change for 3.6, but I want to test it 
with importlib_resources first, since I'll probably have to spin a new release 
of that package too.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32872] backport of #32305 causes regressions in various packages

2018-02-25 Thread Ned Deily

Ned Deily  added the comment:

Thanks, Barry!  I don't see that either action is ideal but I am concerned 
about breaking third-party packages and 2 (already known) breakages is 
worrisome.  And thanks, @doko, for bringing the matter up.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31454] Include "import as" in tutorial

2018-02-25 Thread miss-islington

miss-islington  added the comment:


New changeset 5a07608d0855e4104e4070328155b52010dec4e7 by Miss Islington (bot) 
in branch '3.6':
bpo-31454: Include information about "import X as Y" in Modules tutorial 
(GH-4041)
https://github.com/python/cpython/commit/5a07608d0855e4104e4070328155b52010dec4e7


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >