[issue32319] re fullmatch error with non greedy modifier

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

No, this is not how fullmatch() works. Otherwise there wouldn't be need to add 
it into the stdlib. You could just check end() of the result.

fullmatch() acts like match() with added \Z. But if the pattern contains 
multiple alternates you need to add \Z at the end of every branch 
(r"foo\Z|bar\Z") or wrap the entire patch in a non-capturing group 
(r"(?:foo|bar)\Z").

--
nosy: +serhiy.storchaka
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



[issue28813] Remove unneeded folded consts after peephole

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Moving constant folding to the AST level (issue29469) have made this patch 
outdated. In any case thank you for your patch Adrian.

--
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed
superseder:  -> AST-level Constant folding

___
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 Serhiy Storchaka

Serhiy Storchaka  added the comment:

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

>>> def foo():
... a = (1,2,3,4,5,6,7,8,9,10)
... 
>>> foo.__code__.co_stacksize
1

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
superseder:  -> AST-level Constant folding

___
Python tracker 

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



[issue32320] Add default value support to collections.namedtuple()

2017-12-14 Thread Raymond Hettinger

New submission from Raymond Hettinger :

Add default argument support and _fields_defaults attribute modeled after 
typing.NamedTuple.

--
components: Library (Lib)
messages: 308282
nosy: rhettinger
priority: normal
severity: normal
stage: patch review
status: open
title: Add default value support to collections.namedtuple()
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



[issue32320] Add default value support to collections.namedtuple()

2017-12-14 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
keywords: +patch
pull_requests: +4748

___
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 Raymond Hettinger

Raymond Hettinger  added the comment:

ISTM, the constant-tracking macros for peephole.c can also be removed, 
essentially reverting back to the simpler cumlc-style code in Py2.5.

--
nosy: +rhettinger

___
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: +4749

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


--
keywords: +patch
pull_requests: +4750
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



[issue32302] test_distutils: test_get_exe_bytes() failure on AppVeyor

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 9e7c136ad8bc8e8eec50c2a8ae5ff02752f695a2 by Victor Stinner in 
branch 'master':
bpo-32302: Fix distutils bdist_wininst for CRT v142 (#4851)
https://github.com/python/cpython/commit/9e7c136ad8bc8e8eec50c2a8ae5ff02752f695a2


--

___
Python tracker 

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



[issue32302] test_distutils: test_get_exe_bytes() failure on AppVeyor

2017-12-14 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4751

___
Python tracker 

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



[issue32225] Implement PEP 562: module __getattr__ and __dir__

2017-12-14 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:


New changeset 5364b5cd7571f2dfa75acd37b388c14ac33fef73 by Ivan Levkivskyi in 
branch 'master':
bpo-32225: Implementation of PEP 562 (#4731)
https://github.com/python/cpython/commit/5364b5cd7571f2dfa75acd37b388c14ac33fef73


--

___
Python tracker 

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



[issue32302] test_distutils: test_get_exe_bytes() failure on AppVeyor

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 645fa19f15cddeec8d882a9e1420173e7516f0e4 by Victor Stinner (Miss 
Islington (bot)) in branch '3.6':
bpo-32302: Fix distutils bdist_wininst for CRT v142 (GH-4851) (#4861)
https://github.com/python/cpython/commit/645fa19f15cddeec8d882a9e1420173e7516f0e4


--

___
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 53f7a7c2814fbfd8a29200926601a32fa48bacb3 by Andrew Svetlov (Mike) 
in branch 'master':
bpo-32297: Few misspellings found in Python source code comments. (#4803)
https://github.com/python/cpython/commit/53f7a7c2814fbfd8a29200926601a32fa48bacb3


--
nosy: +asvetlov

___
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 374c6e178a7599aae46c857b17c6c8bc19dfe4c2 by Victor Stinner in 
branch 'master':
bpo-32030: Add _PyMainInterpreterConfig.warnoptions (#4855)
https://github.com/python/cpython/commit/374c6e178a7599aae46c857b17c6c8bc19dfe4c2


--

___
Python tracker 

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



[issue32302] test_distutils: test_get_exe_bytes() failure on AppVeyor

2017-12-14 Thread STINNER Victor

STINNER Victor  added the comment:

It seems like AppVeyor is fixed, thanks Steve for the help!

Later, it would be nice to write a more generic fix than hardcoding two minor 
versions.

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



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

2017-12-14 Thread Andrew Svetlov

Change by Andrew Svetlov :


--
resolution:  -> fixed
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



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

2017-12-14 Thread Andrew Svetlov

Change by Andrew Svetlov :


--
pull_requests: +4752

___
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

Change by INADA Naoki :


--
pull_requests: +4753

___
Python tracker 

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



[issue32225] Implement PEP 562: module __getattr__ and __dir__

2017-12-14 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

Travis build on master successful, so I am closing this issue.

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



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

2017-12-14 Thread Andrew Svetlov

Change by Andrew Svetlov :


--
pull_requests: +4754

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

This adds an overhead to every indexing.

$ ./python -m perf timeit --compare-to=./python0 -s 'a = [1]' --duplicate=1 
'a[0]'
python0: . 15.3 ns +- 0.5 ns
python: . 16.1 ns +- 0.3 ns

Mean +- std dev: [python0] 15.3 ns +- 0.5 ns -> [python] 16.1 ns +- 0.3 ns: 
1.05x slower (+5%)

$ ./python -m perf timeit --compare-to=./python0 -s 'd = {1: 2}' 
--duplicate=1 'd[1]'
python0: . 17.6 ns +- 0.6 ns
python: . 18.4 ns +- 0.5 ns

Mean +- std dev: [python0] 17.6 ns +- 0.6 ns -> [python] 18.4 ns +- 0.5 ns: 
1.05x slower (+5%)

--

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

I think Giuseppe's patch is good, but there's a Windows failure on AppVeyor, so 
I'm a little wary. It doesn't look related, but I haven't looked at Python on 
Windows since... 2001, maybe?

--

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

With "bad assumption" I mean that currently the code assumes that all unknown 
systems has big enough default thread stack size. This would not be a "bad 
assumption" if POSIX (or any other standard) would specify a requirement on the 
default stack size. To my understanding, there are no such requirement in the 
spec, and thus, applications can not really assume anything about the default 
thread stack size.

musl libc does not provide any __MUSL__ macro by design, because they consider 
"it’s a bug to assume a certain implementation has particular properties rather 
than testing" so we cannot really make exception for musl.

https://wiki.musl-libc.org/faq.html#Q:_Why_is_there_no___MUSL___macro?

I think the options we have are:
- at run time, use pthread_attr_getstacksize() to verify we have enough stack 
size. I don't know how to calculate the proper minimum, but some testing showed 
that we need 450k on musl x86_64 to reach sys.getrecursionlimit() so I'd say 
1MB is a good limit - atleast for x86_64.
- at build time, run pthread_attr_getstacksize() from configure script to 
detect default stack size. This will not work for cross compile.
- reverse the current #ifdef behavior so that we check for known systems that 
has big enough system default (eg __GLIBC__ etc) and then fall back to 
something safe for everything else.
- Do nothing. Systems with low stack needs to figure out to add 
-DTHREAD_STACK_SIZE=0x10 to the CFLAGS (this is what Alpine does right now)

I can of course make a check for musl in the configure script and special case 
it, but it still does not fix the issue: There is no guarantee that stack size 
is big enough for python's use for every existing and unknown future system.

--

___
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 ran a test of pthread_attr_getstacksize() on various systems. Here is what 
they return:

Linux/glibc:  8388608
MacOS: 524288
FreeBSD 11.1:   0  (ulimit -s gives 524288)
NetBSD 7.1:   4194304
OpenBSD 6.2:   524288

I could not see any #ifdef for __OpenBSD__ so I would expect to see segfaults 
on OpenBSD as well. Google gave me this:

https://bugs.python.org/issue25342
https://github.com/alonho/pytrace/issues/8

--

___
Python tracker 

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



[issue1346238] A constant folding optimization pass for the AST

2017-12-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Have been implemented in issue29469.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> AST-level Constant folding

___
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



[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



[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



[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



[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



[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



[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



[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



[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



[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



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



[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



[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



[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(&attrs, &tss) != 0) {
+pthread_attr_destroy(&attrs);
+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(&attrs, tss) != 0) {
 pthread_attr_destroy(&attrs);


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



[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



[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 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(&attrs, &tss) != 0)
+   goto thread_abort;
+   if (tss != 0 && tss < THREAD_STACK_MIN_DEFAULT)
+   tss = THREAD_STACK_MIN_DEFAULT;
+}
 if (tss != 0) {
-if (pthread_attr_setstacksize(&attrs, tss) != 0) {
-pthread_attr_destroy(&attrs);
-return PYTHREAD_INVALID_THREAD_ID;
-}
+if (pthread_attr_setstacksize(&attrs, 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(&attrs);
 #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 Марк Коренберг

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



[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



[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



[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



[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



[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



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

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



[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



[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



[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



[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



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



[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



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

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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



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



[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



[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



[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



[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



[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



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

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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



  1   2   >