[issue32332] Implement slots support for magic methods added in PEP 560

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

This isn't so easy. You can't just access new slot, because this is binary 
incompatible. You should add new type flag, say Py_TPFLAGS_HAVE_CLASS, set it 
for all classes with tp_as_class, and guard access to tp_as_class with

if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS))

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32264] move pygetopt.h into internal/

2017-12-14 Thread Benjamin Peterson

Benjamin Peterson  added the comment:


New changeset e425bd75177ffb7f098bdb0618b4a5ba3211fe52 by Benjamin Peterson in 
branch 'master':
move pygetopt.h to internal (closes bpo-32264) (#4830)
https://github.com/python/cpython/commit/e425bd75177ffb7f098bdb0618b4a5ba3211fe52


--
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



[issue32311] Implement asyncio.create_task() shortcut

2017-12-14 Thread Yury Selivanov

Yury Selivanov  added the comment:

Thank you, Andrew!

--

___
Python tracker 

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



[issue32332] Implement slots support for magic methods added in PEP 560

2017-12-14 Thread Yury Selivanov

Change by Yury Selivanov :


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

___
Python tracker 

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



[issue32332] Implement slots support for magic methods added in PEP 560

2017-12-14 Thread Yury Selivanov

New submission from Yury Selivanov :

I propose to add type slots for magic methods introduced by PEP 560.  In the 
brief discussion on the mailing list Guido OK'd the idea: 
https://mail.python.org/pipermail/python-dev/2017-December/151262.html

I'll submit a PR that implements this proposal by adding new 'tp_as_class' 
slot, that points to a PyClassMethods struct, that has two fields: `cm_getitem` 
and `cm_mro_entries`.

Interestingly, when __class_getitem__ is implemented through the type/slots 
machinery it becomes a bit faster.  Given the following microbenchmark:

class Foo:
def __class_getitem__(cls, o):
return o

for _ in range(3):
t = time.monotonic()
for i in range(10 ** 8):
assert i == Foo[i]
print(f'{time.monotonic() - t:.3f}s')

I see these numbers for the master branch:

17.161s
17.024s
16.530s

and these for the C-slots branch:

15.010s
15.693s
15.035s

--
components: Interpreter Core
messages: 308365
nosy: gvanrossum, levkivskyi, pitrou, yselivanov
priority: normal
severity: normal
status: open
title: Implement slots support for magic methods added in PEP 560
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



[issue32311] Implement asyncio.create_task() shortcut

2017-12-14 Thread Andrew Svetlov

Change by Andrew Svetlov :


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

___
Python tracker 

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



[issue32311] Implement asyncio.create_task() shortcut

2017-12-14 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset f74ef458ab1f502e4e60bd1502ac1dc0d2cb3847 by Andrew Svetlov in 
branch 'master':
bpo-32311: Implement asyncio.create_task() shortcut (#4848)
https://github.com/python/cpython/commit/f74ef458ab1f502e4e60bd1502ac1dc0d2cb3847


--

___
Python tracker 

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



[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-14 Thread Yury Selivanov

Change by Yury Selivanov :


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

___
Python tracker 

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



[issue32331] apply SOCK_TYPE_MASK to socket.type on Linux

2017-12-14 Thread Yury Selivanov

New submission from Yury Selivanov :

On Linux, socket type is both a socket type and a bit mask (of SOCK_CLOEXEC and 
SOCK_NONBLOCK).  Therefore, anyone who write code like 'if sock.type == 
SOCK_STREAM' writes non-portable code, that occasionally breaks on Linux.  

This caused some hard to spot bugs in asyncio already: 
https://bugs.python.org/issue27456  -- this one was discovered only 1 year 
after the actual change.

On Linux, in 'include/linux/net.h' there's a SOCK_TYPE_MASK macro defined to 
0xF.  The idea is that on Linux you should mask socket type before comparing it 
to SOCK_STREAM or other socket types.

Using socket.SOCK_NONBLOCK on Python was always error-prone even if one targets 
only Linux.  For instance, socket.type won't be updated to include 
SOCK_NONBLOCK if the socket was updated via ioctl call directly.

Therefore, I propose to fix socket.type getter to always (on Linux) apply that 
mask in Python.

--
components: Library (Lib)
messages: 308363
nosy: asvetlov, inada.naoki, pitrou, vstinner, yselivanov
priority: normal
severity: normal
status: open
title: apply SOCK_TYPE_MASK to socket.type on Linux
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



[issue32330] Email parser creates a message object that can't be flattened

2017-12-14 Thread Mark Sapiro

Mark Sapiro  added the comment:

Yes. I think errors=replace is a good solution. In Mailman, we have our own 
mailman.email.message.Message class which is a subclass of 
email.message.Message and what we do to work around this and issue27321 is 
override as_string() with:

def as_string(self):
# Work around for https://bugs.python.org/issue27321 and
# https://bugs.python.org/issue32330.
try:
value = email.message.Message.as_string(self)
except (KeyError, UnicodeEncodeError):
value = email.message.Message.as_bytes(self).decode(
'ascii', 'replace')
return value

--

___
Python tracker 

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



[issue32330] Email parser creates a message object that can't be flattened

2017-12-14 Thread R. David Murray

R. David Murray  added the comment:

What would you like to see happen in that situation?  Should we use 
errors=replace like we do for headers?  (That seems reasonable to me.)

Note that it can be re-serialized as binary.

--

___
Python tracker 

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



[issue32327] Make asyncio methods documented as coroutines - coroutines.

2017-12-14 Thread Yury Selivanov

Change by Yury Selivanov :


--
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



[issue32327] Make asyncio methods documented as coroutines - coroutines.

2017-12-14 Thread Yury Selivanov

Yury Selivanov  added the comment:


New changeset 19a44f63c738388ef3c8515348b4ffc061dfd627 by Yury Selivanov in 
branch 'master':
bpo-32327: Convert asyncio functions documented as coroutines to coroutines. 
(#4872)
https://github.com/python/cpython/commit/19a44f63c738388ef3c8515348b4ffc061dfd627


--

___
Python tracker 

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 41264f1cd4d6066b2797ff07cae465c1e06ff3b2 by Victor Stinner in 
branch 'master':
bpo-32030: Add _PyMainInterpreterConfig.executable (#4876)
https://github.com/python/cpython/commit/41264f1cd4d6066b2797ff07cae465c1e06ff3b2


--

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Never mind.  I see it's in bytes.  I missed that the first time.  But, if it 
wasn't in bytes, would that be an OK solution?  Or is it bad to override those 
methods in that class?

--

___
Python tracker 

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4770

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

I'm missing something here, so please forgive me for asking, but why is it bad 
to add:

def keys(self):
return self._data.keys()

def values(self):
return self._data.values()

def items(self):
return self._data.items()

to the _Environ class?

--

___
Python tracker 

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset da273412c4374de07a500e7f23f89a6bb7527398 by Victor Stinner in 
branch 'master':
bpo-32030: Add _PyCoreConfig_Copy() (#4874)
https://github.com/python/cpython/commit/da273412c4374de07a500e7f23f89a6bb7527398


--

___
Python tracker 

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



[issue32329] PYTHONHASHSEED=0 python3 -R should enable hash randomization

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

"PYTHONHASHSEED=0 python3 -R" now enables hash randomization on master (Python 
3.7), I also fixed the sys.flags.hash_randomization value when using 
PYTHONHASHSEED=0.

I chose to not modify the behaviour of the -R option in Python 3.6. I dislike 
having to document a behaviour change in a minor Python version (3.6.x). I only 
fixed the value of sys.flags.hash_randomization in Python 3.6.

--

___
Python tracker 

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



[issue32329] PYTHONHASHSEED=0 python3 -R should enable hash randomization

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 22097aaa77b4f0473552fe840358d77e5b9a253f by Victor Stinner in 
branch '3.6':
bpo-32329: Fix sys.flags.hash_randomization (#4875)
https://github.com/python/cpython/commit/22097aaa77b4f0473552fe840358d77e5b9a253f


--

___
Python tracker 

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



[issue32330] Email parser creates a message object that can't be flattened

2017-12-14 Thread Mark Sapiro

New submission from Mark Sapiro :

This is related to https://bugs.python.org/issue27321 but a different exception 
is thrown for a different reason. This is caused by a defective spam message. I 
don't actually have the offending message from the wild, but the attached 
bad_email_2.eml illustrates the problem.

The defect is the message declares the content charset as us-ascii, but the 
body contains non-ascii. When the message is parsed into an 
email.message.Message object and the objects as_string() method is called, 
UnicodeEncodeError is thrown as follows:

>>> import email
>>> with open('bad_email_2.eml', 'rb') as fp:
... msg = email.message_from_binary_file(fp)
... 
>>> msg.as_string()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/email/message.py", line 159, in as_string
g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib/python3.5/email/generator.py", line 115, in flatten
self._write(msg)
  File "/usr/lib/python3.5/email/generator.py", line 181, in _write
self._dispatch(msg)
  File "/usr/lib/python3.5/email/generator.py", line 214, in _dispatch
meth(msg)
  File "/usr/lib/python3.5/email/generator.py", line 243, in _handle_text
msg.set_payload(payload, charset)
  File "/usr/lib/python3.5/email/message.py", line 316, in set_payload
payload = payload.encode(charset.output_charset)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-33: 
ordinal not in range(128)

--
components: email
files: bad_email_2.eml
messages: 308353
nosy: barry, msapiro, r.david.murray
priority: normal
severity: normal
status: open
title: Email parser creates a message object that can't be flattened
type: behavior
versions: Python 3.5, Python 3.6
Added file: https://bugs.python.org/file47333/bad_email_2.eml

___
Python tracker 

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



[issue32326] Update Build projects to version 10.0.16299.0 of the Windows 10 SDK.

2017-12-14 Thread Steve Dower

Steve Dower  added the comment:

It has been resolved in master, so we just need to backport 
PCbuild/python.props to get it in earlier branches.

--

___
Python tracker 

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



[issue32226] Implement PEP 560: Core support for typing module and generic types

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

It is very to get stable benchmarks with timings shorter than 1 ms, and even 
harder for timings shorter than 1 us.

I wrote documentation to implement how to get more stable results:
http://perf.readthedocs.io/en/latest/run_benchmark.html#how-to-get-reproductible-benchmark-results

On Linux, using CPU isolation helps a lot, and perf uses automatically isolated 
CPUs.

--

___
Python tracker 

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



[issue20329] zipfile.extractall fails in Posix shell with utf-8 filename

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

> I created an environment under 3.3.1 in which this error was still occurring, 
> but within that same environment, it is not occurring for 3.7.  I believe 
> this can be closed.

Python 3.7 now uses the UTF-8 encoding when the LC_CTYPE locale is POSIX (PEP 
538, PEP 540). You should still be able to reproduce the bug with a locale with 
an encoding different than UTF-8.

Moreover, I understand that Python 3.6 is still affected by the bug.

I don't think that we can fix this bug, sadly. But I'm happy to see that the 
PEP 538 and PEP 540 are already useful!

--

___
Python tracker 

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



[issue32329] PYTHONHASHSEED=0 python3 -R should enable hash randomization

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4769

___
Python tracker 

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 358e5e17a51ba00742bfaee4557a94c3c4179c22 by Victor Stinner in 
branch 'master':
bpo-32329: Fix -R option for hash randomization (#4873)
https://github.com/python/cpython/commit/358e5e17a51ba00742bfaee4557a94c3c4179c22


--

___
Python tracker 

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



[issue32329] PYTHONHASHSEED=0 python3 -R should enable hash randomization

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 358e5e17a51ba00742bfaee4557a94c3c4179c22 by Victor Stinner in 
branch 'master':
bpo-32329: Fix -R option for hash randomization (#4873)
https://github.com/python/cpython/commit/358e5e17a51ba00742bfaee4557a94c3c4179c22


--

___
Python tracker 

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



[issue32226] Implement PEP 560: Core support for typing module and generic types

2017-12-14 Thread Guido van Rossum

Guido van Rossum  added the comment:

I think the best thing to do is not to panic! Also maybe PGO could help?

On Dec 14, 2017 15:43, "Ivan Levkivskyi"  wrote:

>
> Ivan Levkivskyi  added the comment:
>
> Interesting. I have noticed similar when I tried to add a fast loop
> proposed by Serhiy. It should save at least one pointer comparison for base
> class, but sometimes it actually led to slow-downs (although very small).
> How can one fight this kind of problems?
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue32226] Implement PEP 560: Core support for typing module and generic types

2017-12-14 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

Interesting. I have noticed similar when I tried to add a fast loop proposed by 
Serhiy. It should save at least one pointer comparison for base class, but 
sometimes it actually led to slow-downs (although very small). How can one 
fight this kind of problems?

--

___
Python tracker 

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4768

___
Python tracker 

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



[issue20329] zipfile.extractall fails in Posix shell with utf-8 filename

2017-12-14 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

I created an environment under 3.3.1 in which this error was still occurring, 
but within that same environment, it is not occurring for 3.7.  I believe this 
can be closed.

--
nosy: +csabella

___
Python tracker 

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



[issue32143] os.statvfs lacks f_fsid

2017-12-14 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr.  added the comment:

This has landed on master and will be part of Python 3.7.

--
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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4767

___
Python tracker 

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



[issue32329] PYTHONHASHSEED=0 python3 -R should enable hash randomization

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


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

___
Python tracker 

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



[issue32329] PYTHONHASHSEED=0 python3 -R should enable hash randomization

2017-12-14 Thread STINNER Victor

New submission from STINNER Victor :

Python pretends that hash randomization is always enabled, but it's not:

$ PYTHONHASHSEED=0 python3 -c 'import sys; print(sys.flags.hash_randomization)'
1
vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -c 'import sys; print(hash("abc"))'
4596069200710135518

=> sys.flags.hash_randomization must be zero


Moreover, the -R flag is always ignored, it's not possible to override the 
PYTHONHASHSEED environment variable:

vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; 
print(sys.flags.hash_randomization)'
1
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'
4596069200710135518
vstinner@apu$ PYTHONHASHSEED=0 python3 -R -c 'import sys; print(hash("abc"))'
4596069200710135518

I expect that -R enables hash randomization and overrides PYTHONHASHSEED 
environment variable.

Attached PR fixes these issues and adds an unit test.

--
messages: 308343
nosy: vstinner
priority: normal
severity: normal
status: open
title: PYTHONHASHSEED=0 python3 -R should enable hash randomization
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



[issue32143] os.statvfs lacks f_fsid

2017-12-14 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr.  added the comment:


New changeset 96a5e50a5de3683b2afd6d680c7ecc4b525986f6 by Fred Drake (Giuseppe 
Scrivano) in branch 'master':
bpo-32143: add f_fsid to os.statvfs() (#4571)
https://github.com/python/cpython/commit/96a5e50a5de3683b2afd6d680c7ecc4b525986f6


--

___
Python tracker 

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



[issue32226] Implement PEP 560: Core support for typing module and generic types

2017-12-14 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:


New changeset 2b5fd1e9ca9318673989e6ccac2c8acadc3809cd by Ivan Levkivskyi in 
branch 'master':
bpo-32226: Implementation of PEP 560 (core components) (#4732)
https://github.com/python/cpython/commit/2b5fd1e9ca9318673989e6ccac2c8acadc3809cd


--

___
Python tracker 

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



[issue17852] Built-in module _io can lose data from buffered files at exit

2017-12-14 Thread Armin Rigo

Change by Armin Rigo :


--
nosy:  -arigo

___
Python tracker 

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



[issue32328] ttk.Treeview: _tkinter.TclError: list element in quotes followed by "; " instead of space

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
assignee:  -> 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



[issue32328] ttk.Treeview: _tkinter.TclError: list element in quotes followed by "; " instead of space

2017-12-14 Thread Joshua Kinard

New submission from Joshua Kinard :

I think I've found another bug with Tkinter's string handling in Python 2.7.14, 
before it passes off to the TCL interpreter when inserting items into a 
ttk.Treeview widget.  Specifically, it doesn't handle strings containing 
semi-colons very well if they are passed in via a kwarg dict.

Below is a simple test case.  The "kw" variable has a 'values' key with a 
string value using single quotes to store the value '" ";':

---
from Tkinter import *
from ttk import *

root = Tk()
tv = Treeview(root, columns=("foobar",))

tv.heading("foobar", text="Foobar!")
tv.column("#0", width=0)
tv.column("foobar", stretch=True, minwidth=100, width=400)
tv.grid()

kw = {'values': '" ";', 'tags': ''}
tv.insert("", END, iid=None, **kw)

root.mainloop()
---

This sample triggers this traceback:

Traceback (most recent call last):
  File "test.py", line 14, in 
tv.insert("", END, iid=None, **kw)
  File "C:\Python27\lib\lib-tk\ttk.py", line 1339, in insert
res = self.tk.call(self._w, "insert", parent, index, *opts)
_tkinter.TclError: list element in quotes followed by ";" instead of space


Furthermore, if the 'values' key is changed to the string 'X:"Y ";', you 
trigger a different traceback:

Traceback (most recent call last):
  File "test.py", line 13, in 
tv.insert("", END, iid=None, **kw)
  File "C:\Python27\lib\lib-tk\ttk.py", line 1339, in insert
res = self.tk.call(self._w, "insert", parent, index, *opts)
_tkinter.TclError: unmatched open quote in list

So definitely a case of something in the parser not handling things properly 
before sending to the TCL interpreter.

I suspect this is similar to Issue #15861.  One can work around this bug by 
checking for either a whitespace or backslash character in the string, and 
wrapping the string in curly braces if so, to disable TCL substitution 
mechanism, and it'll insert the string and display it correctly in the widget.

I have only verified this in Python 2.7.14 at the moment, which is what I 
primarily work in right now.

--
components: Tkinter
messages: 308340
nosy: kumba
priority: normal
severity: normal
status: open
title: ttk.Treeview: _tkinter.TclError: list element in quotes followed by ";" 
instead of space
type: behavior
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



[issue32327] Make asyncio methods documented as coroutines - coroutines.

2017-12-14 Thread Yury Selivanov

Change by Yury Selivanov :


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

___
Python tracker 

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



[issue32327] Make asyncio methods documented as coroutines - coroutines.

2017-12-14 Thread Yury Selivanov

Change by Yury Selivanov :


--
nosy: +asvetlov

___
Python tracker 

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



[issue32327] Make asyncio methods documented as coroutines - coroutines.

2017-12-14 Thread Yury Selivanov

New submission from Yury Selivanov :

There's a handful of event loop methods that are currently documented as 
coroutines, but in reality they return asyncio.Future:

* loop.sock_sendall, 
* loop.sock_accept, 
* loop.sock_recv, and 
* loop.run_in_executor.

These methods need to become proper coroutines beacause:

1. loop.create_task(loop.sock_recv(..)) fails with a cryptic error.

2. It's harder for us to refactor the code keeping these functions as regular 
functions returning Futures.  Once asyncio was broken because of the bug in 
loop.sock_connect() because of a complex refactoring.  After we converted it to 
a coroutine in 3.6, we received 0 complaints, but the code became simpler.

3. It's easier to read the source code of asyncio, when all methods that are 
documented as coroutines are actually coroutines.

4. This downgrades the role of 'asyncio.ensure_future()' function.  Basically, 
when a user needs a task, they can now use create_task() (which won't fail on 
some "coroutines" sometimes).  asyncio users will be advised to design APIs in 
their programs and libraries around async/await and not Future objects.

--
assignee: yselivanov
components: asyncio
messages: 308339
nosy: yselivanov
priority: normal
severity: normal
status: open
title: Make asyncio methods documented as coroutines - coroutines.
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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Aaron Meurer

Aaron Meurer  added the comment:

Can't third party code write their own proxies? Why do we have to do that?

--

___
Python tracker 

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



[issue28393] Update encoding lookup docs wrt #27938

2017-12-14 Thread Ville Skyttä

Ville Skyttä  added the comment:

I'm getting a 500 internatl server error trying to update 
https://bugs.python.org/review/28393/, so noting here that the latest review 
issue has been addressed in https://github.com/python/cpython/pull/4871

--

___
Python tracker 

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



[issue27938] PyUnicode_AsEncodedString, PyUnicode_Decode: add fast-path for "us-ascii" encoding

2017-12-14 Thread Ville Skyttä

Change by Ville Skyttä :


--
pull_requests: +4763

___
Python tracker 

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



[issue28393] Update encoding lookup docs wrt #27938

2017-12-14 Thread Ville Skyttä

Change by Ville Skyttä :


--
pull_requests: +4762

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

With option 4 we need to add a custom wrapper not only for Shelf's KeysView, 
but for KeysView of all similar proxy classes, including classes in third-party 
code not available for us. This is impossible.

--

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Aaron Meurer

Aaron Meurer  added the comment:

Serhiy, isn't option 4?

4. Make KeysView.__repr__ show list(self). Add a custom wrapper for Shelf's 
KeysView so that it doesn't do this. 

This seems to be what Victor is suggesting. It makes the most sense to me for 
the common (i.e., default) case to be to show the keys (and just the keys), and 
for use cases that want otherwise to subclass and modify.

--

___
Python tracker 

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



[issue32326] Update Build projects to version 10.0.16299.0 of the Windows 10 SDK.

2017-12-14 Thread Decorater

Change by Decorater :


--
components: +Build, Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue32326] Update Build projects to version 10.0.16299.0 of the Windows 10 SDK.

2017-12-14 Thread Decorater

New submission from Decorater :

It seems that When I uninstalled an older version of the Windows 10 SDK to make 
more disk space to update Visual Studio that now python 3.6 will not compile. I 
am not sure if Python 3.7 on master currently has this issue or not though I 
still have not tested it on 3.7 either.

I am using Visual Studio 2017 to Compile the latest commit on branch 3.6. I 
could technically use branch master if the issue with Py_DecodeLocale() is 
fixed yet though.

--
messages: 308333
nosy: Decorater
priority: normal
severity: normal
status: open
title: Update Build projects to version 10.0.16299.0 of the Windows 10 SDK.
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



[issue17852] Built-in module _io can lose data from buffered files at exit

2017-12-14 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

The reason Python 2 did well here is simply that Python 2 had a single Python 
object (the file object) for each actual file.  Python 3 has several of them 
(the raw IO object, the buffered IO object, possibly the text IO wrapper), and 
so suddenly the finalization order matters.

--

___
Python tracker 

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



[issue32324] [Security] "python3 directory" inserts "directory" at sys.path[0] even in isolated mode

2017-12-14 Thread Brett Cannon

Brett Cannon  added the comment:

Since the directory is where the code that is being executed exists don't you 
have to implicitly trust that directory is secure? Otherwise how can you even 
trust the code you're choosing to execute?

--
nosy: +christian.heimes

___
Python tracker 

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



[issue17852] Built-in module _io can lose data from buffered files at exit

2017-12-14 Thread Neil Schemenauer

Neil Schemenauer  added the comment:

Attached is a script that triggers the non-flushing behaviour for me.  I don't 
think it is reliable since it depends on the order that FileIO AND 
BufferedWriter are finalized when the gc finds them in a reference cycle.

BTW, it is arguable that the root cause of this bug is that we no longer to 
topological ordering when calling finalizers.  Originally, the cycle GC would 
refuse to call __del__ methods because once they are part of a cycle, there is 
no defined topological ordering.  So, we linked that garage to gc.garbage 
rather than calling __del__ and have potentially undefined results.  Now the GC 
has been changed to call __del__ anyhow.   I haven't studied how this has been 
changed but this non-flushing bug is a result.  Having the buffer added to 
gc.garbage would also result in the data not being flushed but arguably it 
would be more understandable what's going on.  I'm not arguing that we should 
go back to that, just that current behaviour can be subtle and confusing.

--
Added file: https://bugs.python.org/file47332/buffer_not_flushed.py

___
Python tracker 

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



[issue32323] urllib.parse.urlsplit() must not lowercase() IPv6 scope value

2017-12-14 Thread Марк Коренберг

Марк Коренберг  added the comment:

Also this:

http://potaroo.net/ietf/idref/draft-kitamura-ipv6-zoneid-free/

So, I'm confused. Will investigate.

--

___
Python tracker 

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



[issue32323] urllib.parse.urlsplit() must not lowercase() IPv6 scope value

2017-12-14 Thread Марк Коренберг

Марк Коренберг  added the comment:

https://url.spec.whatwg.org/#host-representation -> Support for  is 
intentionally omitted.

https://tools.ietf.org/html/rfc6874

--

___
Python tracker 

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



[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
status: open -> closed

___
Python tracker 

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



[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 15a8728415e765f57e37f431f09e5c5821a04063 by Serhiy Storchaka in 
branch 'master':
bpo-29469: Optimize literal lists and sets iterating on the AST level. (#4866)
https://github.com/python/cpython/commit/15a8728415e765f57e37f431f09e5c5821a04063


--

___
Python tracker 

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



[issue32323] urllib.parse.urlsplit() must not lowercase() IPv6 scope value

2017-12-14 Thread R. David Murray

R. David Murray  added the comment:

In quick search the only RFC reference to this I found was 
https://tools.ietf.org/id/draft-sweet-uri-zoneid-01.html, which doesn't match 
what you are requesting (not that urlsplit's current behavior matches that 
either).  

Do you have RFC references?

--
nosy: +r.david.murray

___
Python tracker 

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



[issue32311] Implement asyncio.create_task() shortcut

2017-12-14 Thread Yury Selivanov

New submission from Yury Selivanov :

There's a lengthy discussion of this proposal over here: 
https://github.com/python/asyncio/issues/477

Guido there likes the idea of adding asyncio.create_task(), so let's add it.

--

___
Python tracker 

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



[issue32277] SystemError via chmod(symlink, ..., follow_symlinks=False)

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
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



[issue32277] SystemError via chmod(symlink, ..., follow_symlinks=False)

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset d1cb1067a82b11280204e36b695e786a5a3ca221 by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.6':
bpo-32277: Fix exception raised from chmod(..., follow_symlinks=False) 
(GH-4797) (#4869)
https://github.com/python/cpython/commit/d1cb1067a82b11280204e36b695e786a5a3ca221


--

___
Python tracker 

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



[issue32226] Implement PEP 560: Core support for typing module and generic types

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I think this is a cause. The difference may be dependent on the compiler and 
platform.

--
nosy: +vstinner

___
Python tracker 

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



[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

PR 4866 also fixes the bug in optimizing chained 'i' and 'not in'.

For example `1 in [1, 2] == [1, 2]` results in False (should be True) because 
it is changed to `1 in (1, 2) == [1, 2]`, and (1, 2) != [1, 2].

--

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Options:

1. Use the subclass of KeyView with overridden __repr__ for os.environ.keys(). 
This will add a code for pretty rare use case.

2. Remove os.environ.__repr__. You can use repr(os.environ.copy()) or 
repr(dict(os.environ)) if you want to see a content.

3. Do not change anything. You can use repr(list(os.environ.keys())) if you 
want to see only keys.

--

___
Python tracker 

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



[issue32277] SystemError via chmod(symlink, ..., follow_symlinks=False)

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I was going to request a test, but the fix is obvious and writing a test for 
this case can be not easy. Thank you Anthony for your report and patch.

--

___
Python tracker 

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



[issue32277] SystemError via chmod(symlink, ..., follow_symlinks=False)

2017-12-14 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4761

___
Python tracker 

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



[issue32277] SystemError via chmod(symlink, ..., follow_symlinks=False)

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 233ef249cc5c18d796fb581747179c5e062b4083 by Serhiy Storchaka 
(Anthony Sottile) in branch 'master':
bpo-32277: Fix exception raised from chmod(..., follow_symlinks=False) (#4797)
https://github.com/python/cpython/commit/233ef249cc5c18d796fb581747179c5e062b4083


--

___
Python tracker 

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



[issue32325] C API should use 'const char *' instead of 'char *'

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

This already was done in issue28761.

--
resolution:  -> out of date
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



[issue32221] Converting ipv6 address to string representation using getnameinfo() is wrong.

2017-12-14 Thread Марк Коренберг

Марк Коренберг  added the comment:

Please look at my PR

--

___
Python tracker 

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



[issue32325] C API should use 'const char *' instead of 'char *'

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32325] C API should use 'const char *' instead of 'char *'

2017-12-14 Thread Stephen Kelly

New submission from Stephen Kelly :

When using C++ to extend python, one may use PyGetSetDef for example:


static PyGetSetDef Noddy_getseters[] = {
{"first",
 (getter)Noddy_getfirst, (setter)Noddy_setfirst,
 "first name",
 NULL},
{"last",
 (getter)Noddy_getlast, (setter)Noddy_setlast,
 "last name",
 NULL},
{NULL}  /* Sentinel */
};

However, in C++ implicit conversion from const char* to char* is deprecated 
since C++98, and is a removed conversion in C++11.

 https://godbolt.org/g/sswUKM

GCC/Clang warn about this, and MSVC in conformance mode (/permissive-) errors 
on it.

PyGetSetDef and similar APIs should use const char* instead of char* for 
members such as `name`.

--
components: Library (Lib)
messages: 308316
nosy: steveire
priority: normal
severity: normal
status: open
title: C API should use 'const char *' instead of 'char *'
type: enhancement
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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

Cheryl: "Thanks!  Yes, I can work this.  It may take a few days for me to get 
to it."

It seems like we have a disagreement on how to fix this issue. We should first 
agree on the best solution.

--

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

Currently, repr(Shelf.keys()) doesn't dump the content of the shelf:

>>> import pickle, shelve
>>> s=shelve.Shelf({b'key': pickle.dumps('value')})
>>> k=s.keys()
>>> k
KeysView()
>>> list(k)
['key']
>>> list(s.values())
['value']

I understand that changing KeysView.__repr__() changes repr(Shelf.keys()) 
behaviour.

--

___
Python tracker 

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



[issue32324] [Security] "python3 directory" inserts "directory" at sys.path[0] even in isolated mode

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

See also https://github.com/python/cpython/pull/4868 : I propose a change to 
factorize the code, but the side effect is that sys.path is now modified before 
"import readline" (when using the -i option, like "python3 -i directory").

--

___
Python tracker 

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



[issue32226] Implement PEP 560: Core support for typing module and generic types

2017-12-14 Thread Guido van Rossum

Guido van Rossum  added the comment:

> This adds an overhead to every indexing.

I'm not doubting your results, but I'm curious how that happened. The extra
code in PyObject_GetItem is right before the point where it would otherwise
raise TypeError -- I presume you benchmark never reached that point. Could
it be that the compiler ends up rearranging the code in a way that is less
optimal for the instruction cache?

--

___
Python tracker 

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



[issue32324] [Security] "python3 directory" inserts "directory" at sys.path[0] even in isolated mode

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

"python3 directory" and "python3 testzip.zip" are implemented by calling 
runpy._run_module_as_main("__main__", set_argv0). Currently, sys.path is 
modified before calling _run_module_as_main().

Would it be possible to pass an additional path to importlib to import 
__main__, without modifying sys.path?

--
nosy: +brett.cannon, ncoghlan

___
Python tracker 

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



[issue32324] [Security] "python3 directory" inserts "directory" at sys.path[0] even in isolated mode

2017-12-14 Thread STINNER Victor

New submission from STINNER Victor :

Christian Heimes, author of the -I option (isolated mode), asked me to open an 
issue to check if the following behaviour is correct (safe in term of security).

"python3 directory" inserts "directory" at sys.path[0], even in isolated mode. 
Example:
---
vstinner@apu$ mkdir directory
vstinner@apu$ echo "import pprint, sys; pprint.pprint(sys.path)" > 
directory/__main__.py

vstinner@apu$ python3 directory
['directory',
 '/usr/lib64/python3.6',
 ...]

# Same behaviour with -I
vstinner@apu$ python3 -I directory
['directory',
 '/usr/lib64/python3.6',
 ...]
---


Same behaviour for a ZIP file:
---
vstinner@apu$ cd directory/
vstinner@apu$ zip ../testzip.zp __main__.py 
  adding: __main__.py (deflated 20%)
vstinner@apu$ cd ..
vstinner@apu$ python3 testzip.zip
python3: can't open file 'testzip.zip': [Errno 2] No such file or directory
vstinner@apu$ mv testzip.zp testzip.zip 
'testzip.zp' -> 'testzip.zip'

vstinner@apu$ python3 testzip.zip
['testzip.zip',
 '/usr/lib64/python3.6',
 ...]

# Same behaviour with -I
vstinner@apu$ python3 -I testzip.zip
['testzip.zip',
 '/usr/lib64/python3.6',
 ...]
---

The -I option:
https://docs.python.org/dev/using/cmdline.html#id2

--
messages: 308310
nosy: steve.dower, vstinner
priority: normal
severity: normal
status: open
title: [Security] "python3 directory" inserts "directory" at sys.path[0] even 
in isolated mode
type: security
versions: Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

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



[issue32300] print(os.environ.keys()) should only print the keys

2017-12-14 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Victor,

Thanks!  Yes, I can work this.  It may take a few days for me to get to it.

--

___
Python tracker 

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-14 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4760

___
Python tracker 

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



[issue32314] Implement asyncio.run()

2017-12-14 Thread Yury Selivanov

Yury Selivanov  added the comment:

> Wow, I really love your new function. Thanks Yury! asyncio examples in the 
> doc look much better now!

This year I'll stay for the sprints at PyCon, and will focus on improving the 
docs further.  I needed asyncio.run for that :)

--

___
Python tracker 

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



[issue32323] urllib.parse.urlsplit() must not lowercase() IPv6 scope value

2017-12-14 Thread Марк Коренберг

Change by Марк Коренберг :


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

___
Python tracker 

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



[issue32307] Bad assumption on thread stack size makes python crash with musl libc

2017-12-14 Thread Natanael Copa

Natanael Copa  added the comment:

Exactly same as previous patch, but refactored to only have a single 
pthread_attr_destroy() call instead of 3.

diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index b7463c0ca6..1006a168fa 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -34,6 +34,8 @@
 #undef  THREAD_STACK_SIZE
 #define THREAD_STACK_SIZE   0x40
 #endif
+/* minimum size of the default thread stack size */
+#define THREAD_STACK_MIN_DEFAULT 0x10
 /* for safety, ensure a viable minimum stacksize */
 #define THREAD_STACK_MIN0x8000  /* 32 KiB */
 #else  /* !_POSIX_THREAD_ATTR_STACKSIZE */
@@ -167,7 +169,7 @@ unsigned long
 PyThread_start_new_thread(void (*func)(void *), void *arg)
 {
 pthread_t th;
-int status;
+int status = -1;
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
 pthread_attr_t attrs;
 #endif
@@ -187,11 +189,15 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
 PyThreadState *tstate = PyThreadState_GET();
 size_t stacksize = tstate ? tstate->interp->pythread_stacksize : 0;
 tss = (stacksize != 0) ? stacksize : THREAD_STACK_SIZE;
+if (tss == 0 && THREAD_STACK_SIZE == 0) {
+if (pthread_attr_getstacksize(, ) != 0)
+   goto thread_abort;
+   if (tss != 0 && tss < THREAD_STACK_MIN_DEFAULT)
+   tss = THREAD_STACK_MIN_DEFAULT;
+}
 if (tss != 0) {
-if (pthread_attr_setstacksize(, tss) != 0) {
-pthread_attr_destroy();
-return PYTHREAD_INVALID_THREAD_ID;
-}
+if (pthread_attr_setstacksize(, tss) != 0)
+   goto thread_abort;
 }
 #endif
 #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
@@ -209,6 +215,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
  );
 
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+thread_abort:
 pthread_attr_destroy();
 #endif
 if (status != 0)

--
nosy:  -serhiy.storchaka, vstinner

___
Python tracker 

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



[issue32323] urllib.parse.urlsplit() must not lowercase() IPv6 scope value

2017-12-14 Thread Марк Коренберг

New submission from Марк Коренберг :

qwe = urlsplit('http://[FE80::822a:a8ff:fe49:470c%Тест]:1234/keys')
qwe.hostname will be 'fe80::822a:a8ff:fe49:470c%тест'

Which is wrong.

correct value is

'fe80::822a:a8ff:fe49:470c%Тест'

so, IP-address is lowercased and zone id does not.

--
components: Library (Lib)
messages: 308306
nosy: socketpair
priority: normal
severity: normal
status: open
title: urllib.parse.urlsplit() must not lowercase() IPv6 scope value
type: behavior
versions: 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



[issue32307] Bad assumption on thread stack size makes python crash with musl libc

2017-12-14 Thread R. David Murray

R. David Murray  added the comment:

I think we need people who do a lot of work at the C level to evaluate this, so 
I've added a couple to the nosy list :)

--
nosy: +serhiy.storchaka, vstinner

___
Python tracker 

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



[issue32307] Bad assumption on thread stack size makes python crash with musl libc

2017-12-14 Thread Natanael Copa

Natanael Copa  added the comment:

I suggest a runtime check like this:

diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index b7463c0ca6..e9d0f638c9 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -34,6 +34,8 @@
 #undef  THREAD_STACK_SIZE
 #define THREAD_STACK_SIZE   0x40
 #endif
+/* minimum size of the default thread stack size */
+#define THREAD_STACK_MIN_DEFAULT 0x10
 /* for safety, ensure a viable minimum stacksize */
 #define THREAD_STACK_MIN0x8000  /* 32 KiB */
 #else  /* !_POSIX_THREAD_ATTR_STACKSIZE */
@@ -187,6 +189,14 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
 PyThreadState *tstate = PyThreadState_GET();
 size_t stacksize = tstate ? tstate->interp->pythread_stacksize : 0;
 tss = (stacksize != 0) ? stacksize : THREAD_STACK_SIZE;
+if (tss == 0 && THREAD_STACK_SIZE == 0) {
+if (pthread_attr_getstacksize(, ) != 0) {
+pthread_attr_destroy();
+return PYTHREAD_INVALID_THREAD_ID;
+}
+   if (tss != 0 && tss < THREAD_STACK_MIN_DEFAULT)
+   tss = THREAD_STACK_MIN_DEFAULT;
+}
 if (tss != 0) {
 if (pthread_attr_setstacksize(, tss) != 0) {
 pthread_attr_destroy();


The reasoning here is:

- if THREAD_STACK_SIZE is set to non-zero, then use that. This is so that you 
can at compile time set the default stack size to your liking. This is 
currently set for __APPLE__ and __FreeBSD__ and you can set it via CFLAGS, so 
this does not change anything for those.
- if THREAD_STACK_SIZE is set to 0, then see if pthread_attr_getstacksize 
returns anything and if it does, make sure that we have at least 1MB stack size 
as default.

Scripts that uses threading.stack_size() will still work as before, and you can 
still manually set the stack size down to 32k (THREAD_STACK_MIN) if you need 
that.

This should keep existing behavior for known systems like glibc, OSX, FreeBSD, 
NetBSD but will raise the thread stack size for musl libc and OpenBSD to 1MB.

What do you think?

--

___
Python tracker 

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



[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
pull_requests: +4757

___
Python tracker 

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



[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
status: closed -> open

___
Python tracker 

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



[issue32314] Implement asyncio.run()

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

Wow, I really love your new function. Thanks Yury! asyncio examples in the doc 
look much better now!

--
nosy: +vstinner

___
Python tracker 

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



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2017-12-14 Thread Rostislav Kondratenko

New submission from Rostislav Kondratenko :

If one creates a type with both Py_TPFLAGS_HAVE_GC and Py_TPFLAGS_HEAPTYPE set 
and implemented, one has to create instances with PyObject_GC_New() per current 
docs: https://docs.python.org/3.7/c-api/gcsupport.html .

However, PyObject_GC_New() unlike PyType_GenericAlloc() does not increment 
refcount of a type object. As the refcount is still decremented when instances 
are destroyed, it leads to steady drain on type object's refcount. Eventually 
it reaches zero and the type object gets deleted while there are still 
instances and references to it. And it usually results in crash after a number 
of instances (20-50 is usually enough) is created and destroyed.

One should either update the docs to point that call to PyType_GenericAlloc() 
would be sufficient (as it would use _PyObject_GC_Malloc() and increment 
refcount when appropriate) or update _PyObject_GC_New() code to increment type 
object's refcount when the type is heap type. Or both.

--
assignee: docs@python
components: Documentation, Interpreter Core
messages: 308302
nosy: docs@python, rkond
priority: normal
severity: normal
status: open
title: Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not 
incrementing type object refcout in PyObject_GC_New
type: crash
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue32314] Implement asyncio.run()

2017-12-14 Thread Yury Selivanov

Change by Yury Selivanov :


--
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



[issue32314] Implement asyncio.run()

2017-12-14 Thread Yury Selivanov

Yury Selivanov  added the comment:


New changeset 02a0a19206da6902c3855a1fa09e60b208474cfa by Yury Selivanov in 
branch 'master':
bpo-32314: Implement asyncio.run() (#4852)
https://github.com/python/cpython/commit/02a0a19206da6902c3855a1fa09e60b208474cfa


--

___
Python tracker 

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



[issue29469] AST-level Constant folding

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

Thank you very much Naoki for taking time to implement this obvious 
"optimization", rewriting the peephole optimizer at the AST level, rather than 
modifying bytecode which is more complex to get it right and had annoying side 
effect (like inefficient stack size, now fixed: bpo-26549).

--

___
Python tracker 

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



[issue32297] Few misspellings found in Python source code comments.

2017-12-14 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset 28453feaa8d88bbcbf6d834b1d5ca396d17265f2 by Andrew Svetlov in 
branch '3.6':
[3.6] bpo-32297: Fix misspellings in Python source code comments (GH-4803) 
(#4864)
https://github.com/python/cpython/commit/28453feaa8d88bbcbf6d834b1d5ca396d17265f2


--

___
Python tracker 

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



[issue21074] Too aggressive constant folding

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
pull_requests: +4756

___
Python tracker 

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



[issue30416] constant folding opens compiler to quadratic time hashing

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
pull_requests: +4755

___
Python tracker 

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



[issue26549] co_stacksize is calculated from unoptimized code

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

> Seems moving constant folding to the AST level (issue29469) have solved this 
> issue.

Wow, it's cool to see this bug finally fixed!

--

___
Python tracker 

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



[issue32321] functools.reduce has a redundant guard or needs a pure Python fallback

2017-12-14 Thread Steven D'Aprano

New submission from Steven D'Aprano :

The functools module imports reduce from _functools, using a guard in case it 
is not present:

try:
from _functools import reduce
except ImportError:
pass


However, the documentation says nothing about reduce being optional, and it is 
unconditionally included in the module __all__.

If reduce is guaranteed to be implemented in _functools, then the guard is 
redundant and should be removed. Otherwise, a pure python fallback should be 
added.

(The docs for reduce include a pure Python equivalent which might be 
sufficient.)

--
components: Library (Lib)
keywords: easy
messages: 308297
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: functools.reduce has a redundant guard or needs a pure Python fallback
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



[issue29469] AST-level Constant folding

2017-12-14 Thread INADA Naoki

INADA Naoki  added the comment:


New changeset eadad1b97f64619bfd246b9d3b60d25f456e0592 by INADA Naoki in branch 
'master':
bpo-29469: Remove unnecessary peephole optimizer (GH-4863)
https://github.com/python/cpython/commit/eadad1b97f64619bfd246b9d3b60d25f456e0592


--

___
Python tracker 

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



[issue27695] Long constant calculations stall compilation

2017-12-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Too aggressive constant folding

___
Python tracker 

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



  1   2   >