[issue29302] add contextlib.AsyncExitStack

2017-09-05 Thread Nathaniel Smith

Changes by Nathaniel Smith :


--
nosy: +njs

___
Python tracker 

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



[issue31333] Implement ABCMeta in C

2017-09-05 Thread Stefan Behnel

Stefan Behnel added the comment:

Since the number of applications that get along without any file access is 
probably close to irrelevant, "os" and "io" feel like sufficiently widely used 
modules to merit being part of a "usual Python startup" benchmark. Maybe we 
should add one to the benchmark suite? Anyone up for it?

--
nosy: +scoder

___
Python tracker 

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



[issue31333] Implement ABCMeta in C

2017-09-05 Thread INADA Naoki

INADA Naoki added the comment:

"python_startup_nosite" benchmark imports io module,
and "python_startup" benchmark imports os too.
So no need to additional test for them.

You can see it with `python -v -S -c 'pass'` and `python -v -c 'pass'`.

--

___
Python tracker 

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



[issue31339] [2.7] time.asctime() crash with year > 9999 using musl C library

2017-09-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Isn't this a duplicate of issue16137 which was closed with the resolution 
"won't fix"?

--
nosy: +belopolsky, benjamin.peterson

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The fact that assert() is compiled out in release build looks as an advantage 
to me. This allows the compiler to generate smaller code. I'm in favor of using 
assert(!"message"), but this form is rarely used in CPython sources.

I think it would be nice to ask on Python-Dev first. Maybe there are other 
concerns.

--
nosy: +haypo, rhettinger

___
Python tracker 

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



[issue24896] It is undocumented that re.UNICODE and re.LOCALE affect re.IGNORECASE

2017-09-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This wording is not correct as I noted in msg294324.

--
versions:  -Python 3.5

___
Python tracker 

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



[issue31345] Backport docstring improvements to the C version of OrderedDict

2017-09-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
keywords: +easy
stage:  -> needs patch

___
Python tracker 

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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2017-09-05 Thread Christian Ullrich

New submission from Christian Ullrich:

I'm trying to do something that may be slightly tricky, and I think I just 
found a vintage 1997 bug. Please correct me if I'm wrong.

This is PC/getpathp.c from current master:

430: static void
431: get_progpath(void)
432: {
433: extern wchar_t *Py_GetProgramName(void);
434: wchar_t *path = _wgetenv(L"PATH");
435: wchar_t *prog = Py_GetProgramName();
436: 
437: #ifdef Py_ENABLE_SHARED
438: extern HANDLE PyWin_DLLhModule;
439: /* static init of progpath ensures final char remains \0 */
440: if (PyWin_DLLhModule)
441: if (!GetModuleFileNameW(PyWin_DLLhModule, dllpath, MAXPATHLEN))
442: dllpath[0] = 0;
443: #else
444: dllpath[0] = 0;
445: #endif
446: if (GetModuleFileNameW(NULL, progpath, MAXPATHLEN))
447: return;
448: if (prog == NULL || *prog == '\0')
449: prog = L"python";

Lines 446-447 have been like this ever since Guido wrote them twenty years ago. 
I think the logic is the wrong way around. As it is now, the function always 
returns on line 447 because GetModuleFileNameW() *always* succeeds (returns 
nonzero). Hence, everything below line 447 is dead code.

GetModuleFileNameW(NULL, ...) fills the buffer with the path to the executable 
the current process was created from. It returns the number of characters put 
into the buffer, or zero on error. However, the only way *this* call could fail 
is if the code was being executed outside of any process, something that 
clearly cannot happen.

Prior to August 1997, the relevant bit of code looked like this:

156:if (!GetModuleFileName(NULL, progpath, MAXPATHLEN))
157:progpath[0] = '\0'; /* failure */


This bug, if it is one, would only manifest when initializing an embedded 
interpreter using a different argv[0] than that of the actual host process, 
because if the host process is a python.exe, it very likely runs inside a 
standard installation or venv anyway. What I am trying is to make an 
interpreter running in a third-party host process take site-packages from a 
venv.

Doing this (argv[0] different from actual host process) may not be entirely 
proper itself, but then again, why would Py_SetProgramName() even exist 
otherwise?

Suggested fix:

diff --git a/PC/getpathp.c b/PC/getpathp.c
index 8380e1bcfa..abb5e54c9f 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -443,8 +443,7 @@ get_progpath(void)
 #else
 dllpath[0] = 0;
 #endif
-if (!GetModuleFileNameW(NULL, progpath, MAXPATHLEN))
-return;
+GetModuleFileNameW(NULL, progpath, MAXPATHLEN);
 if (prog == NULL || *prog == '\0')
 prog = L"python";

Since the call to GetModuleFileNameW() cannot possibly fail, there is no real 
point in checking its return value.

--
components: Windows
messages: 301306
nosy: Christian.Ullrich, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Embedded initialization ignores Py_SetProgramName()
type: behavior
versions: 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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2017-09-05 Thread Christian Ullrich

Christian Ullrich added the comment:

That should have been 

diff --git a/PC/getpathp.c b/PC/getpathp.c
index e7be704a9a..abb5e54c9f 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -443,8 +443,7 @@ get_progpath(void)
 #else
 dllpath[0] = 0;
 #endif
-if (GetModuleFileNameW(NULL, progpath, MAXPATHLEN))
-return;
+GetModuleFileNameW(NULL, progpath, MAXPATHLEN);
 if (prog == NULL || *prog == '\0')
 prog = L"python";

instead, of course, without the negation.

--

___
Python tracker 

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



[issue31334] select.poll.poll fails on BSDs with arbitrary negative timeouts

2017-09-05 Thread Riccardo Coccioli

Riccardo Coccioli added the comment:

This can actually be reproduced with Python 2.7 too (thanks @thiell to let me 
know). At first I thought that it was not because it doesn't repro with the 
stock macOS-shipped Python 2.7.10 on macOS Sierra 10.12.6, where the 
select.poll() is not available at all, see below.

Updated list of version where I was able to reproduce the error:
- macOS Sierra 10.12.6 with those Python versions: 2.7.10, 2.7.13, 3.3.6, 
3.4.6, 3.5.3, 3.6.2, 3.7.0a0 (heads/master:2ef37607b7)
- FreeBSD 11.1 with those Python versions: 2.7.13, 3.7.0a0 
(heads/master:2ef37607b7)

For reference, the repro code executed with the stock macOS-shipped Python:
#--
$ /usr/bin/python
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import select
>>> p = select.poll()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'poll'
#--

If the PR 3277 that I've sent against the master branch with the fix will be 
accepted, I'm ready to send additional PRs to backport the fix in all affected 
versions.

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



[issue6396] '' % object() raises TypeError

2017-09-05 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Under 3.7, the examples Terry gave now have consistent results.

>>> '' % A()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: not all arguments converted during string formatting

>>> '' % object()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: not all arguments converted during string formatting

>>> '%(a)s' % object()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: format requires a mapping

>>> '%(a)s' % A()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: format requires a mapping

--
nosy: +csabella

___
Python tracker 

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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Christian Heimes

Changes by Christian Heimes :


--
pull_requests: +3353

___
Python tracker 

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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset c941e6238ab2a8caad11fe17d4723a5d5e7a2d76 by Christian Heimes in 
branch 'master':
bpo-30102: Call OPENSSL_add_all_algorithms_noconf (#3112)
https://github.com/python/cpython/commit/c941e6238ab2a8caad11fe17d4723a5d5e7a2d76


--

___
Python tracker 

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



[issue31343] Include major(), minor(), makedev() from sysmacros

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset 75b961869a1184895c9d5bf41a57f3c985622662 by Christian Heimes in 
branch 'master':
bpo-31343: Include sys/sysmacros.h (#3318)
https://github.com/python/cpython/commit/75b961869a1184895c9d5bf41a57f3c985622662


--

___
Python tracker 

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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Christian Heimes

Changes by Christian Heimes :


--
pull_requests: +3354

___
Python tracker 

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



[issue31343] Include major(), minor(), makedev() from sysmacros

2017-09-05 Thread Christian Heimes

Changes by Christian Heimes :


--
pull_requests: +3356

___
Python tracker 

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



[issue31343] Include major(), minor(), makedev() from sysmacros

2017-09-05 Thread Christian Heimes

Changes by Christian Heimes :


--
pull_requests: +3355

___
Python tracker 

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



[issue30622] Fix NPN guard for OpenSSL 1.1

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset 7316c6d4a57931e9786c06eae168b227d7463317 by Christian Heimes in 
branch '3.6':
[3.6] bpo-30622: Change NPN detection: (GH-2079) (#3314)
https://github.com/python/cpython/commit/7316c6d4a57931e9786c06eae168b227d7463317


--

___
Python tracker 

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



[issue30622] Fix NPN guard for OpenSSL 1.1

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:

Thanks for your patch!

I have merged it into master, 3.6, and 2.7. The other branches are in security 
fix-only mode.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
type:  -> compile error
versions: +Python 3.7 -Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I'm thinking there are two aspects to this.  One would involve updates to PEP 7 
to include a section on "Unreachable code".  The other would be a PR that 
updates the current C code to the PEP 7 standard.

I'll work on a PEP update as a separate PR, then we can discuss further on 
python-dev.  If the PEP changes are accepted, then we can manage the code 
changes as a PR against this issue.

--

___
Python tracker 

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



[issue31343] Include major(), minor(), makedev() from sysmacros

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset ffa7011cb904ee6ad9d4931b073c13d9e1514e6b by Christian Heimes in 
branch '2.7':
[2.7] bpo-31343: Include sys/sysmacros.h (GH-3318) (#3345)
https://github.com/python/cpython/commit/ffa7011cb904ee6ad9d4931b073c13d9e1514e6b


--

___
Python tracker 

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



[issue31343] Include major(), minor(), makedev() from sysmacros

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset 02854dab6231d726fa2c63d44ab25598988c44f4 by Christian Heimes in 
branch '3.6':
[3.6] bpo-31343: Include sys/sysmacros.h (GH-3318) (#3344)
https://github.com/python/cpython/commit/02854dab6231d726fa2c63d44ab25598988c44f4


--

___
Python tracker 

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



[issue31343] Include major(), minor(), makedev() from sysmacros

2017-09-05 Thread Christian Heimes

Changes by Christian Heimes :


--
resolution:  -> fixed
stage: needs patch -> 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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset 2ddea0f098b42dfd74f53bcbf08c8e68c83e1049 by Christian Heimes in 
branch '3.6':
[3.6] bpo-30102: Call OPENSSL_add_all_algorithms_noconf (GH-3112) (#3342)
https://github.com/python/cpython/commit/2ddea0f098b42dfd74f53bcbf08c8e68c83e1049


--

___
Python tracker 

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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset 7daa45db1d60eed4e5050bf792969893d9f2c8e0 by Christian Heimes in 
branch '2.7':
[2.7] bpo-30102: Call OPENSSL_add_all_algorithms_noconf (GH-3112) (#3343)
https://github.com/python/cpython/commit/7daa45db1d60eed4e5050bf792969893d9f2c8e0


--

___
Python tracker 

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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:

Thanks for your persistence and your initial patch.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
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



[issue30102] improve performance of libSSL usage on hashing

2017-09-05 Thread Gustavo Serra Scalet

Gustavo Serra Scalet added the comment:

No worries. I thank you also for reviewing all these changesets. I'm glad it 
worked in the end.

--

___
Python tracker 

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



[issue14976] queue.Queue() is not reentrant, so signals and GC can cause deadlocks

2017-09-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> Would it make sense get() and put() to add gc.disable() and gc.enable() 
> whenever GC is already enabled?

That doesn't sound very nice if some thread is waiting on a get() for a very 
long time (which is reasonable if you have a thread pool that's only used 
sporadically, for example).  Also, using gc.disable() and gc.enable() in 
multi-threaded programs is a bit delicate.

--

___
Python tracker 

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



[issue14976] queue.Queue() is not reentrant, so signals and GC can cause deadlocks

2017-09-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't mind someone to reimplement a full-fledged Queue in C.  As for me, I am 
currently implementing a SimpleQueue in C that's reentrant and has only the 
most basic functionality.

--

___
Python tracker 

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



[issue14976] queue.Queue() is not reentrant, so signals and GC can cause deadlocks

2017-09-05 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
pull_requests: +3357

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

@skrah - quick question.  Is /* NOT REACHED */ a common convention?  Do any 
compilers or IDEs recognize it?  Is it documented anywhere?  I like the idea of 
adding that comment on the abort(), but I'm trying to find some prior art or 
references for that.

--

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Can we have a Py_UNREACHABLE() macro for that, then?
First, it makes the intent extra clear without needing any additional comment.  
Second, it can be defined however we need in order to get along with the 
various tools around.

--
nosy: +pitrou

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

> 
> Can we have a Py_UNREACHABLE() macro for that, then?
> First, it makes the intent extra clear without needing any additional 
> comment.  Second, it can be defined however we need in order to get along 
> with the various tools around.

+1

--

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
pull_requests: +3358

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Stefan Krah

Stefan Krah added the comment:

> Is /* NOT REACHED */ a common convention?

I think it's often used in BSD, I first saw it in OpenBSD.


A macro is fine of course.

--

___
Python tracker 

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



[issue30450] Pull Windows dependencies from GitHub rather than svn.python.org

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> New changeset 986b7ffc650919b3022ccaa458a843bb8a95d2bd by Zachary Ware in 
> branch '2.7':
> [2.7] bpo-30450: Pull Windows dependencies from GitHub rather than SVN 
> (GH-1783) (GH-3306)

This change broke Python 2.7 compilation on Windows XP.

Pending fix: PR 3330.

--

___
Python tracker 

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



[issue30450] Pull Windows dependencies from GitHub rather than svn.python.org

2017-09-05 Thread Zachary Ware

Changes by Zachary Ware :


--
pull_requests: +3359

___
Python tracker 

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



[issue30450] Pull Windows dependencies from GitHub rather than svn.python.org

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> New changeset 986b7ffc650919b3022ccaa458a843bb8a95d2bd by Zachary Ware in 
> branch '2.7':
> [2.7] bpo-30450: Pull Windows dependencies from GitHub rather than SVN 
> (GH-1783) (GH-3306)

This change also broke compilation on AMD64 Windows10 2.7 buildbot:
http://buildbot.python.org/all/builders/AMD64%20Windows10%202.7/builds/279



"D:\buildarea\2.7.bolen-windows10\build\PCbuild\pcbuild.proj" (Build target) 
(1) ->
"D:\buildarea\2.7.bolen-windows10\build\PCbuild\pythoncore.vcxproj" (Build 
target) (2) ->
(Manifest target) -> 
  C:\Program Files 
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(574,5): error 
MSB6006: "mt.exe" exited with code -1073741819. 
[D:\buildarea\2.7.bolen-windows10\build\PCbuild\pythoncore.vcxproj]

260 Warning(s)
1 Error(s)

--

___
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 loose data from buffered files at exit

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> New changeset e38d12ed34870c140016bef1e0ff10c8c3d3f213 by Neil Schemenauer in 
> branch 'master':
> bpo-17852: Maintain a list of BufferedWriter objects.  Flush them on exit. 
> (#1908)

This change introduced a regression:



==
FAIL: test_4_daemon_threads (test.test_threading.ThreadJoinOnShutdown)
--
Traceback (most recent call last):
  File 
"/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_threading.py", line 
781, in test_4_daemon_threads
self.assertFalse(err)
AssertionError: b'pthread_cond_destroy: Resource busy\npthread_mutex_destroy: 
Resource busy' is not false

http://buildbot.python.org/all/builders/x86%20Tiger%203.x/builds/1137

> New changeset db564238db440d4a2d8eb9d60ffb94ef291f6d30 by Neil Schemenauer in 
> branch 'master':
> Revert "bpo-17852: Maintain a list of BufferedWriter objects.  Flush them on 
> exit. (#1908)" (#3337)

This revert fixed the regression.

Did you revert the change because of the failure?

--

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Stefan Krah

Stefan Krah added the comment:

And Solaris lint recognizes it:

   https://docs.oracle.com/cd/E60778_01/pdf/E60745.pdf

Actually it could be that the convention comes right from K&R, but I
can't find my copy right now.

--

___
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 loose data from buffered files at exit

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> FAIL: test_4_daemon_threads (test.test_threading.ThreadJoinOnShutdown)

Oh, it also failed on:

http://buildbot.python.org/all/builders/x86%20Gentoo%20Installed%20with%20X%203.x/builds/957/steps/test/logs/stdio

and

http://buildbot.python.org/all/builders/x86%20Gentoo%20Non-Debug%20with%20X%203.x/builds/942/steps/test/logs/stdio

--

___
Python tracker 

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



[issue31326] concurrent.futures: ProcessPoolExecutor.shutdown(wait=True) should wait for the call queue thread

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

Antoine Pitrou: "I don't terribly like this being backported. It does not fix 
any user-visible problem AFAIK."

https://github.com/python/cpython/pull/3309#issuecomment-327231614

Ok, let's close this issue.

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



[issue31339] [2.7] time.asctime() crash with year > 9999 using musl C library

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> Isn't this a duplicate of issue16137 which was closed with the resolution 
> "won't fix"?

This issue seems to be a crash on Windows using negative year. You proposed a 
patch using asctime_s() instead of asctime(). So the fix is specific to Windows.

This issue is now qualified as a security vulnerability (msg301255), so we have 
to fix it.

My proposed PR 3293 fixes the crash on musl, it should fix issue16137 crash on 
Windows, and indirectly it adds support for year >  on all platforms which 
is a nice side effect.

--

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Can we use compiler-specific code like GCC's __builtin_unreachable()? This 
would help the optimizer.

--

___
Python tracker 

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



[issue6396] '' % object() raises TypeError, '' % A() does not

2017-09-05 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The issue History suggests that the original report was marked for 2.6, 3.0, 
3.1.  It is not clear which versions the OP or anyone else tested.  I removed 
the versions above and added 3.2, 3.3 after reporting a test on 3.2.0.  I did 
not report 2.7 behavior and don't know when 2.7 was added.

In any case, 2.7.13 has the same % behavior as 3.6 (and 3.7):

>>> '' % 1
...
TypeError: not all arguments converted during string formatting

So someone or ones decided to resolve the inconsistency in a manner the 
opposite of what Martin suggested.

''.format(1, 2, 3) *does* ignore the extra arguments, but I will not call the 
difference between % and .format a bug, as it appears intentional.  With f 
strings, there is no issue of 'extra arguments

I augmented the title to be clearer that the issue was the inconsistency, which 
is now gone.  Thanks, Cheryl, for rechecking.

--
components: +Interpreter Core
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
title: '' % object() raises TypeError -> '' % object() raises TypeError, '' % 
A() does not

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> As suggested in http://bugs.python.org/issue31337#msg301229 it would be 
> better to use
> abort() /* NOT REACHED */

Please don't use abort(), but add a new Py_UNREACHABLE() macro to allow to use 
a different code depending on the compiler/platform and compiler option (like 
release vs debug build).

> Can we use compiler-specific code like GCC's __builtin_unreachable()? This 
> would help the optimizer.

That's a good example of better implementation for Py_UNREACHABLE().

The tricky part is to make compiler warnings quiet. For example, you cannot 
replace "abort(); return NULL;" with "abort()", because a function without 
return would emit a warning.

Maybe the default implementation of the macro should be:

#define Py_UNREACHABLE(stmt) abort(); stmt

I don't know if it would work.

--

___
Python tracker 

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



[issue31069] test_multiprocessing_spawn and test_multiprocessing_forkserver leak dangling processes

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

Too bad, the bug is not dead, I reopen the issue.

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%2010.x%20Shared%203.x/builds/800/steps/test/logs/stdio

test_rlock (test.test_multiprocessing_forkserver.WithThreadsTestLock) ... ok
test_rapid_restart 
(test.test_multiprocessing_forkserver.WithThreadsTestManagerRestart) ... ok
Warning -- Dangling processes: {}
test_boundaries (test.test_multiprocessing_forkserver.WithThreadsTestPoll) ... 
ok
test_dont_merge (test.test_multiprocessing_forkserver.WithThreadsTestPoll) ... 
ok

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le 05/09/2017 à 19:10, STINNER Victor a écrit :
> 
> Maybe the default implementation of the macro should be:
> 
> #define Py_UNREACHABLE(stmt) abort(); stmt

Or simply you would write:

Py_UNREACHABLE();
return NULL;

--

___
Python tracker 

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



[issue30502] Fix buffer handling of OBJ_obj2txt

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset f201e886fc7aaeb50f5e945578c6aec2a59a5323 by Christian Heimes in 
branch '3.6':
[3.6] bpo-30502: Fix handling of long oids in ssl. (GH-2909) (#3321)
https://github.com/python/cpython/commit/f201e886fc7aaeb50f5e945578c6aec2a59a5323


--

___
Python tracker 

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



[issue30502] Fix buffer handling of OBJ_obj2txt

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset c9d668c0d8a6f3e8e72345e53d1dd34be172f16e by Christian Heimes in 
branch '2.7':
[2.7] bpo-30502: Fix handling of long oids in ssl. (GH-2909). (#3322)
https://github.com/python/cpython/commit/c9d668c0d8a6f3e8e72345e53d1dd34be172f16e


--

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> Or simply you would write:
>
>Py_UNREACHABLE();
> return NULL;

I recall that I had to fix warnings when using clang on:

Py_FatalError("...");
return NULL;

See bpo-28152.

I don't know if it's related to this issue.

--

___
Python tracker 

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



[issue31350] Optimize get_event_loop and _get_running_loop

2017-09-05 Thread Jimmy Lai

New submission from Jimmy Lai:

get_event_loop() and _get_running_loop() can be faster.

CaseTimeMeanImprove 


No Change   7.323 +- 0.172  7.323   0.00%   


Remove class _RunningLoop   6.513 +- 0.115  6.513   -11.06% 


Expand _get_running_loop() inside get_event_loop()  5.851 +- 0.160  5.851   
-20.10% 


Use Tuple instead of two attributes 6.179 +- 0.099  6.179   -15.62% 


Tuple + Remove _RunningLoop 6.026 +- 0.123  6.026   -17.71% 


Tuple + return ternary + Remove _RunningLoop6.060 +- 0.111  6.06-17.25% 



Combine all four optimizations  4.735 +- 0.111  4.735   -35.34% 


Remove class _RunningLoop + Use Tuple instead of two attributes 6.241 +- 0.097  
6.241   -14.78% 

Experimenting with different techniques to optimize get_event_loop and 
_get_running_loop.  
 

After discuss with Yuri, decide not to expand _get_running_loop inside 
get_event_loop.
Combine tuple in _running_loop and Remove _RunningLoop (just use 
threading.local) can achieve the best improvement: 17.71% faster.

--
components: asyncio
messages: 301342
nosy: jimmylai, yselivanov
priority: normal
pull_requests: 3360
severity: normal
status: open
title: Optimize get_event_loop and _get_running_loop
versions: 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



[issue31350] Optimize get_event_loop and _get_running_loop

2017-09-05 Thread Jimmy Lai

Changes by Jimmy Lai :


--
type:  -> performance

___
Python tracker 

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



[issue31350] Optimize get_event_loop and _get_running_loop

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

Can you please provide the code of your benchmark?

--
nosy: +haypo

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
title: Optimize get_event_loop and _get_running_loop -> asyncio: Optimize 
get_event_loop and _get_running_loop

___
Python tracker 

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



[issue30450] Pull Windows dependencies from GitHub rather than svn.python.org

2017-09-05 Thread Zachary Ware

Changes by Zachary Ware :


--
pull_requests: +3361

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread Jimmy Lai

Jimmy Lai added the comment:

Benchmark script: Run 10 times to get mean and stdev


import asyncio
import time

async def async_get_loop():
start_time = time.time()
for _ in range(500):
asyncio.get_event_loop()
return time.time() - start_time

loop = asyncio.get_event_loop()
results = []
for _ in range(10):
start_time = time.time()
result = loop.run_until_complete(async_get_loop())
results.append(result)

import statistics
print("elapse time: %.3lf +- %.3lf secs" % (statistics.mean(results), 
statistics.stdev(results)))

--

___
Python tracker 

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



[issue29627] configparser.ConfigParser.read() has undocumented/unexpected behaviour when given a bytestring path.

2017-09-05 Thread Łukasz Langa

Changes by Łukasz Langa :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> ConfigParser.read silently fails if filenames argument is a 
byte string

___
Python tracker 

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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2017-09-05 Thread Steve Dower

Steve Dower added the comment:

You're right, though I disagree with the fix as that would cause the process 
filename to be ignored.

A correct fix would check whether the name has been set explicitly and if so, 
either use it as-is (if absolute) or get the actual name and use its directory 
(since there's no point searching PATH as we'll likely just find some other 
executable and hence not be able to initialize).

As this is a subtle change in behaviour, we should only do it for 3.7. For 3.6 
and earlier I'd suggest naming your executable the name that you'd like it to 
be, as that will work fine in this case and anywhere else we assume that the 
process name is the name of the process. (The fact that the behaviour is wrong 
in earlier versions is overridden IMO by the fact that it has been wrong for a 
decade and nobody has complained, and there is a trivial workaround.)

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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2017-09-05 Thread Christian Ullrich

Christian Ullrich added the comment:

Not quite. Looking a bit further down get_progname()'s weird logic, we see that 
it works like this:

1. prog = Py_GetProgramName()
2. progpath = GetModuleFileNameW()
3. if (prog is empty):
   prog = "python"
4. if (slash in prog):  # Or backslash, of course
   progpath = prog

So it uses the host process name from step 2 (i.e. progpath) whenever 
Py_SetProgramName() has not been used and step 3 has set prog to a value not 
containing a directory separator (or if it *has* been used to set something 
with no such separator in it).

The logic makes sense, I think, but it is quite impenetrable. Any chance of PEP 
432 ("Restructuring the CPython startup sequence") happening this century?

--

___
Python tracker 

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



[issue31336] Speed up _PyType_Lookup() for class creation

2017-09-05 Thread Stefan Behnel

Stefan Behnel added the comment:

I updated the pull request with a split version of _PyType_Lookup() that 
bypasses the method cache during slot updates. I also ran the benchmarks with 
PGO enabled now to get realistic results. The overall gain is around 15%.

Original:
$ ./python -m timeit 'class Test: pass'
2 loops, best of 5: 7.29 usec per loop

Patched:
$ ./python -m timeit 'class Test: pass'
5 loops, best of 5: 6.15 usec per loop

Patched with non-trivial bases:
$ ./python -m timeit 'class Test(object): pass'
5 loops, best of 5: 6.05 usec per loop
$ ./python -m timeit 'class Test(type): pass'
5 loops, best of 5: 6.08 usec per loop
$ ./python -m timeit 'class Test(int): pass'
5 loops, best of 5: 9.08 usec per loop

I do not consider the optimisations a code degredation.

There is one semantic change: the new function _PyType_LookupUncached() returns 
on the first error and might set an exception. I considered that better 
behaviour than the old function, but it means that if one base class name 
lookup fails and the next one previously succeeded, it will no longer succeed 
now. I don't have a strong feeling about this and would change it back if 
compatibility is considered more valuable. It generally feels wrong to have 
errors pass silently here, however unlikely they may be in practice.

--

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

I suggest to use my perf module to run benchmark, especially if the tested 
function takes less than 1 ms, which is the case here.

Attached benchmark script calls asyncio.get_event_loop(). Result on the master 
branch with PR 3347:

haypo@selma$ ./python ~/bench_asyncio.py --inherit=PYTHONPATH -o patch.json
haypo@selma$ ./python ~/bench_asyncio.py --inherit=PYTHONPATH -o ref.json
haypo@selma$ ./python -m perf compare_to ref.json patch.json 

Mean +- std dev: [ref] 881 ns +- 42 ns -> [patch] 859 ns +- 14 ns: 1.03x faster 
(-3%)

I'm not convinced that the PR is worth it. 3% is not interesting on a micro 
benchmark.

Or is there an issue in my benchmark?

--
Added file: http://bugs.python.org/file47120/bench_asyncio.py

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread Stefan Krah

Stefan Krah added the comment:

On Tue, Sep 05, 2017 at 05:10:24PM +, STINNER Victor wrote:
> That's a good example of better implementation for Py_UNREACHABLE().
> 
> The tricky part is to make compiler warnings quiet. For example, you cannot 
> replace "abort(); return NULL;" with "abort()", because a function without 
> return would emit a warning.

Which compiler needs more than "abort();" in a default statement? gcc and clang
don't.

--

___
Python tracker 

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



[issue31336] Speed up _PyType_Lookup() for class creation

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

Please use perf.timeit not timeit for microbenchmarks: 
https://perf.readthedocs.io/en/latest/

--

___
Python tracker 

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



[issue27448] Race condition in subprocess.Popen which causes a huge memory leak

2017-09-05 Thread Gregory P. Smith

Gregory P. Smith added the comment:


New changeset 5e8e371364ee58dadb9a4e4e51c7e9cf6bedbfae by Gregory P. Smith in 
branch '2.7':
bpo-27448: Work around a gc.disable race condition in subprocess. (#1932)
https://github.com/python/cpython/commit/5e8e371364ee58dadb9a4e4e51c7e9cf6bedbfae


--

___
Python tracker 

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



[issue27448] Race condition in subprocess.Popen which causes a huge memory leak

2017-09-05 Thread Gregory P. Smith

Gregory P. Smith added the comment:

the recommendation to use subprocess32 still stands, but this bug has been 
"fixed" in as much as it can be without a complete rewrite within 2.7.

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



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

2017-09-05 Thread Neil Schemenauer

Neil Schemenauer added the comment:

I reverted because of the crash in test_threading.  I'm pretty sure there is a 
bug with the locking of bufferedio.c, related to threads and flush.  Here is 
the stacktrace I get (my patch applied, I'm trying to write a Python test that 
triggers the SEGV without my flush patch).

Attached is the script that triggers the crash.


Thread 3 received signal SIGSEGV, Segmentation fault.
0x0001000c06d4 in PyObject_GetAttr (
v=, name='seek')
at ../Objects/object.c:882
882 PyTypeObject *tp = Py_TYPE(v);
(gdb) bt
#0  0x0001000c06d4 in PyObject_GetAttr (
v=, name='seek')
at ../Objects/object.c:882
#1  0x0001000440e9 in PyObject_CallMethodObjArgs (
callable=, name='seek')
at ../Objects/call.c:1212
#2  0x0001003005a2 in _buffered_raw_seek (self=0x1053a39b8, target=0,
whence=1) at ../Modules/_io/bufferedio.c:742
#3  0x00010030015e in buffered_flush_and_rewind_unlocked (self=0x1053a39b8)
at ../Modules/_io/bufferedio.c:851
#4  0x0001002fed12 in buffered_flush (self=0x1053a39b8, args=0x0)
at ../Modules/_io/bufferedio.c:869
#5  0x0001002feb4d in _PyIO_atexit_flush ()
at ../Modules/_io/bufferedio.c:1863
[...]

--
Added file: http://bugs.python.org/file47121/buffer_crash.py

___
Python tracker 

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



[issue29708] support reproducible Python builds

2017-09-05 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I have proposed PEP 552 to address this issue.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue31338] Use abort() for code we never expect to hit

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

> Which compiler needs more than "abort();" in a default statement? gcc and 
> clang don't.

Again, I'm not sure that bpo-28152 is directly related to this issue, but here 
an example:

$ git diff

diff --git a/Parser/grammar.c b/Parser/grammar.c
index 75fd5b9cde..2b7da68929 100644
--- a/Parser/grammar.c
+++ b/Parser/grammar.c
@@ -139,13 +139,6 @@ findlabel(labellist *ll, int type, const char *str)
 }
 fprintf(stderr, "Label %d/'%s' not found\n", type, str);
 Py_FatalError("grammar.c:findlabel()");
-
-/* Py_FatalError() is declared with __attribute__((__noreturn__)).
-   GCC emits a warning without "return 0;" (compiler bug!), but Clang is
-   smarter and emits a warning on the return... */
-#ifndef __clang__
-return 0; /* Make gcc -Wall happy */
-#endif
 }
 
 /* Forward */

$ make

Parser/grammar.c: In function '_Py_findlabel':
Parser/grammar.c:142:1: warning: control reaches end of non-void function 
[-Wreturn-type]

--

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread Yury Selivanov

Yury Selivanov added the comment:

> I'm not convinced that the PR is worth it. 3% is not interesting on a micro 
> benchmark.

I found a small issue in the PR (left a comment in the PR).

I think using a tuple is still a good idea (even if the speedup is tiny) 
because logically, both attributes on that threading.local() object are always 
set and read at the same time.  Essentially, it's a pair of (loop, pid), so 
using a tuple here makes the code easier to reason about.

--

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

If the motivation is correctness and not performance, please adjust the issue 
and PR description :-)

--

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread Yury Selivanov

Yury Selivanov added the comment:

> Or is there an issue in my benchmark?

Yes.  The correct benchmark would be to measure `get_event_loop` performance 
from *within* a running event loop.

--

___
Python tracker 

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



[issue31170] Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3362

___
Python tracker 

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



[issue31170] Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3363

___
Python tracker 

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



[issue31170] Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3365

___
Python tracker 

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



[issue30947] Update embeded copy of libexpat from 2.2.1 to 2.2.3

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3364

___
Python tracker 

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



[issue31170] Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3367

___
Python tracker 

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



[issue30947] Update embeded copy of libexpat from 2.2.1 to 2.2.3

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3366

___
Python tracker 

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



[issue31170] Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3369

___
Python tracker 

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



[issue30947] Update embeded copy of libexpat from 2.2.1 to 2.2.3

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3368

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


Added file: http://bugs.python.org/file47122/bench_get_event_loop.py

___
Python tracker 

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



[issue31350] asyncio: Optimize get_event_loop and _get_running_loop

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

According to Jimmy, asyncio.get_event_loop() behaves differently if it's called 
while an event loop is running. So my first benchmark was wrong.

Attached bench_get_event_loop.py measures asyncio.get_event_loop() performance 
when an event loop is running. I get a different result: 

haypo@selma$ ./python -m perf compare_to ref.json patch.json 
Mean +- std dev: [ref] 555 ns +- 11 ns -> [patch] 498 ns +- 11 ns: 1.11x faster 
(-10%)

Ok, now it's 10% faster :-)

--

___
Python tracker 

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



[issue29988] (async) with blocks and try/finally are not as KeyboardInterrupt-safe as one might like

2017-09-05 Thread Nick Coghlan

Nick Coghlan added the comment:

https://github.com/ncoghlan/cpython/pull/2/files now adds a DEFER_PENDING_UNTIL 
opcode that relies on the jump offset calculation machinery to decide how long 
pending call processing should be deferred.

Right now, the test case is also emulating the "skip pending call" logic based 
on a frame attribute, but I'm going to try to replace that with a suitable call 
to _testcapi._pending_threadfunc, which would avoid the need to expose those 
details on the frame, and ensure that we're testing the logic that actually 
matters.

However, the good news is that:

1. the patch is complete enough that I think it demonstrates that this approach 
is potentially viable
2. because it only suspends pending call process in the *current* frame, it's 
safe to cross boundaries that may call arbitrary Python code (this turns out to 
be important for the async with case)

--

___
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 loose data from buffered files at exit

2017-09-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Just apply the following patch to the original PR and it should work fine:

diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 50c87c1..2ba98f2 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -409,12 +409,12 @@ static void
 buffered_dealloc(buffered *self)
 {
 self->finalizing = 1;
+if (self->next != NULL)
+remove_from_linked_list(self);
 if (_PyIOBase_finalize((PyObject *) self) < 0)
 return;
 _PyObject_GC_UNTRACK(self);
 self->ok = 0;
-if (self->next != NULL)
-remove_from_linked_list(self);
 if (self->weakreflist != NULL)
 PyObject_ClearWeakRefs((PyObject *)self);
 Py_CLEAR(self->raw);
@@ -1860,8 +1860,12 @@ void _PyIO_atexit_flush(void)
 while (buffer_list_end.next != &buffer_list_end) {
 buffered *buf = buffer_list_end.next;
 remove_from_linked_list(buf);
-buffered_flush(buf, NULL);
-PyErr_Clear();
+if (buf->ok && !buf->finalizing) {
+Py_INCREF(buf);
+buffered_flush(buf, NULL);
+Py_DECREF(buf);
+PyErr_Clear();
+}
 }
 }

--
nosy: +pitrou
versions: +Python 3.6, Python 3.7 -Python 3.4, Python 3.5

___
Python tracker 

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



[issue31344] f_trace_opcodes frame attribute to switch to per-opcode tracing

2017-09-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The f_trace attribute is writable from a tracing function. There are different 
restrictions, for example you can't jump inside a 'for' loop from outside. The 
code of the setter is complex and hard for modifications (see the discussion on 
PR 2827). Allowing to trace opcodes can make it more complex.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue31336] Speed up _PyType_Lookup() for class creation

2017-09-05 Thread Stefan Behnel

Stefan Behnel added the comment:

Since I'm getting highly reproducible results on re-runs, I tend to trust these 
numbers.

--

___
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 loose data from buffered files at exit

2017-09-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

To elaborate a bit on the patch:
- it is pointless to call flush() if the buffered is in a bad state (self->ok 
== 0) or it has started finalizing already
- you need to own the reference, since flush() can release the GIL and, if the 
reference is borrowed, the refcount can fall to 0 in another thread and the 
whole object deallocated under your feet

--

___
Python tracker 

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



[issue30450] Pull Windows dependencies from GitHub rather than svn.python.org

2017-09-05 Thread Zachary Ware

Zachary Ware added the comment:


New changeset 8905fb831cf7c400c479b79bb2f90bfbe9c71337 by Zachary Ware in 
branch '2.7':
bpo-30450: Don't use where, XP doesn't have it (GH-3348)
https://github.com/python/cpython/commit/8905fb831cf7c400c479b79bb2f90bfbe9c71337


--

___
Python tracker 

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



[issue31344] f_trace_opcodes frame attribute to switch to per-opcode tracing

2017-09-05 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Adding Ned to CC in case he wants to comment on the utility of per-opcode 
tracing from the perspective of coverage.py.

--
nosy: +nedbat, njs

___
Python tracker 

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



[issue31351] ensurepip discards pip's return code which leads to broken venvs

2017-09-05 Thread Igor Filatov

New submission from Igor Filatov:

ensurepip runs pip with a function that discards the result code that pip 
produces:

def _run_pip(args, additional_paths=None):
# ...
pip.main(args)

pip.main() is designed not to raise command exceptions. Instead it returns exit 
codes which are to be passed to sys.exit(). Since ensurepip does not process 
the return value of pip.main() in any way, python -m ensurepip always exits 
with 0 on such exceptions (even though there's a stack trace, printing of which 
is handled by pip). EC should be 0 only in case of success.

This is an issue in venv because it runs ensurepip in a subprocess and cannot 
detect a failure:

def _setup_pip(self, context):
# ...
cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade',
'--default-pip']
subprocess.check_output(cmd, stderr=subprocess.STDOUT)

And this leads to broken venvs in some cases. The easiest way to reproduce:

$ mkdir venv-test
$ cd venv-test/
$ echo garbage > setup.cfg
$ python3 -m venv broken
$ broken/bin/pip
bash: broken/bin/pip: No such file or directory

There are no errors until you need pip. The culprit is this:

$ broken/bin/python -Im ensurepip --upgrade --default-pip
Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Collecting pip
Collecting pkg_resources
Installing collected packages: setuptools, pip, pkg-resources
Exception:
Traceback (most recent call last):
  File 
"/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/basecommand.py", line 209, 
in main
status = self.run(options, args)
  File 
"/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/commands/install.py", line 
335, in run
prefix=options.prefix_path,
  File 
"/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/req/req_set.py", line 732, 
in install
**kwargs
  File 
"/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/req/req_install.py", line 
837, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File 
"/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/req/req_install.py", line 
1039, in move_wheel_files
isolated=self.isolated,
  File "/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/wheel.py", line 
247, in move_wheel_files
prefix=prefix,
  File "/tmp/tmpgjpdbf_e/pip-8.1.1-py2.py3-none-any.whl/pip/locations.py", 
line 141, in distutils_scheme
d.parse_config_files()
  File "/usr/lib/python3.5/distutils/dist.py", line 395, in 
parse_config_files
parser.read(filename)
  File "/usr/lib/python3.5/configparser.py", line 696, in read
self._read(fp, filename)
  File "/usr/lib/python3.5/configparser.py", line 1077, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: 'setup.cfg', line: 1
'garbage\n'

But any other exception during pip any_command would've had the same effect. 
This is hard to diagnose because no output is produced by subprocess due to the 
exception. 

ensurepip should propagate the code returned by pip and pass it to sys.exit(). 
Alternatively ensurepip can have it's own EC for cases when pip.main(args) != 0.

--
components: Library (Lib)
messages: 301367
nosy: Igor Filatov
priority: normal
severity: normal
status: open
title: ensurepip discards pip's return code which leads to broken venvs
type: behavior
versions: Python 3.4, 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



[issue30465] FormattedValue expressions have wrong lineno and col_offset information

2017-09-05 Thread Eric V. Smith

Eric V. Smith added the comment:

See also issue 31140: I'm not sure if that case is covered by this issue.

--

___
Python tracker 

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



[issue31352] Tracis CI coverage job fails on Python 3.6

2017-09-05 Thread STINNER Victor

New submission from STINNER Victor:

haypo@selma$ ./python -m venv env
haypo@selma$ env/bin/python -m pip install coverage
haypo@selma$ ./env/bin/python -m coverage run --pylib -m test -uall,-cpu 
test_traceback
(...)
==
FAIL: test_recursive_traceback_cpython_internal 
(test.test_traceback.TracebackFormatTests)
--
Traceback (most recent call last):
  File "/home/haypo/prog/python/3.6/Lib/test/test_traceback.py", line 431, in 
test_recursive_traceback_cpython_internal
self._check_recursive_traceback_display(render_exc)
  File "/home/haypo/prog/python/3.6/Lib/test/test_traceback.py", line 347, in 
_check_recursive_traceback_display
self.assertEqual(actual[-1], expected[-1])
AssertionError: 'RecursionError: maximum recursion depth exceeded in 
comparison' != 'RecursionError: maximum recursion depth exceeded'
- RecursionError: maximum recursion depth exceeded in comparison
? --
+ RecursionError: maximum recursion depth exceeded


==
FAIL: test_recursive_traceback_python (test.test_traceback.TracebackFormatTests)
--
Traceback (most recent call last):
  File "/home/haypo/prog/python/3.6/Lib/test/test_traceback.py", line 423, in 
test_recursive_traceback_python
self._check_recursive_traceback_display(traceback.print_exc)
  File "/home/haypo/prog/python/3.6/Lib/test/test_traceback.py", line 347, in 
_check_recursive_traceback_display
self.assertEqual(actual[-1], expected[-1])
AssertionError: 'RecursionError: maximum recursion depth exceeded in 
comparison' != 'RecursionError: maximum recursion depth exceeded'
- RecursionError: maximum recursion depth exceeded in comparison
? --
+ RecursionError: maximum recursion depth exceeded

--
messages: 301369
nosy: haypo
priority: normal
severity: normal
status: open
title: Tracis CI coverage job fails on Python 3.6
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



[issue29334] ssl.SSLObject method getpeercert() is buggy, do_handshake() is strange

2017-09-05 Thread Christian Heimes

Christian Heimes added the comment:


New changeset 63b3f2b19cc96801c3b8619e4cf8aa9028e7a33c by Christian Heimes in 
branch '3.6':
[3.6] bpo-29334: Fix ssl.getpeercert for auto-handshake (GH-1769) (#1778)
https://github.com/python/cpython/commit/63b3f2b19cc96801c3b8619e4cf8aa9028e7a33c


--

___
Python tracker 

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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2017-09-05 Thread Steve Dower

Steve Dower added the comment:

People are working on PEP 432 this week at the sprints, so yeah, it's likely.

--

___
Python tracker 

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



[issue31353] Implement PEP 553 - built-in debug()

2017-09-05 Thread Barry A. Warsaw

New submission from Barry A. Warsaw:

Placeholder issue for discussion of the design of the implementation of PEP 553.

--
assignee: barry
components: Interpreter Core
messages: 301372
nosy: barry
priority: normal
severity: normal
status: open
title: Implement PEP 553 - built-in debug()
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



[issue31353] Implement PEP 553 - built-in debug()

2017-09-05 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
pull_requests: +3370

___
Python tracker 

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



[issue30445] test_traceback fails in coverage run

2017-09-05 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +3371

___
Python tracker 

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



[issue31352] Tracis CI coverage job fails on Python 3.6

2017-09-05 Thread STINNER Victor

STINNER Victor added the comment:

Duplicate of bpo-30445.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> test_traceback fails in coverage run

___
Python tracker 

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



[issue30445] test_traceback fails in coverage run

2017-09-05 Thread Zachary Ware

Changes by Zachary Ware :


--
pull_requests: +3372

___
Python tracker 

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



[issue31344] f_trace_opcodes frame attribute to switch to per-opcode tracing

2017-09-05 Thread Nick Coghlan

Nick Coghlan added the comment:

Steve's also requested the ability to *turn off* line debugging, and I'm 
thinking it may make sense to allow all four configurations:

* both line and opcode events disabled
* only getting one or the other
* getting both kinds of event

Opcode events would definitely be off by default, and if you do turn them on, 
then you'd be in a situation similar to importing ctypes: the interpreter is no 
longer guaranteed to work correctly. (Although unlike ctypes, you shouldn't get 
segfaults because of it)

--

___
Python tracker 

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



  1   2   3   >