[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Sebastian Rittau

Change by Sebastian Rittau :


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

___
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-13 Thread Aaron Meurer

New submission from Aaron Meurer :

Take the following scenario which happened to me recently. I am trying to debug 
an issue on Travis CI involving environment variables. Basically, I am not sure 
if an environment variable is being set correctly. So in my code, I put

print(os.environ.keys())

The reason I put keys() was 1, I didn't care about the values, and 2, I have 
secure environment variables set on Travis. 

To my surprise, in the Travis logs, I found something like this

KeysView(environ({'TRAVIS_STACK_FEATURES': 'basic cassandra chromium couchdb 
disabled-ipv6 docker docker-compose elasticsearch firefox go-toolchain 
google-chrome jdk memcached mongodb mysql neo4j nodejs_interpreter 
perl_interpreter perlbrew phantomjs postgresql python_interpreter rabbitmq 
redis riak ruby_interpreter sqlite xserver', 'CI': 'true', ..., 'MANPATH': 
'/home/travis/.nvm/versions/node/v7.4.0/share/man:/home/travis/.kiex/elixirs/elixir-1.4.5/man:/home/travis/.rvm/rubies/ruby-2.4.1/share/man:/usr/local/man:/usr/local/clang-3.9.0/share/man:/usr/local/share/man:/usr/share/man:/home/travis/.rvm/man'}))

So instead of just printing the keys like I asked for, it printed the whole 
environment, plus "KeysView(environ(". Included here was my secure environment 
variable. 

Now, fortunately, Travis hides the contents of secure environment variables in 
the logs, but it didn't used to 
(https://blog.travis-ci.com/2017-05-08-security-advisory).

Aside from being a potential security issue, it's just annoying that it prints 
the whole environment. The values are much larger than the keys. With a normal 
dictionary, print(d.keys()) just prints the keys:

>>> print(dict(a=1, b=2).keys())
dict_keys(['a', 'b'])

--
messages: 308190
nosy: Aaron.Meurer
priority: normal
severity: normal
status: open
title: print(os.environ.keys()) should only print the keys
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



[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Andrew Svetlov

Change by Andrew Svetlov :


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



[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset c3e070f84931c847d1b35e7fb36aa71edd6215f6 by Andrew Svetlov 
(Sebastian Rittau) in branch 'master':
bpo-32284: Fix documentation of BinaryIO and TextIO (#4832)
https://github.com/python/cpython/commit/c3e070f84931c847d1b35e7fb36aa71edd6215f6


--
nosy: +asvetlov

___
Python tracker 

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



[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4725

___
Python tracker 

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



[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:


New changeset b0358e8784821867ab05b3d890717c37309be849 by Andrew Svetlov (Miss 
Islington (bot)) in branch '3.6':
bpo-32284: Fix documentation of BinaryIO and TextIO (GH-4832) (#4833)
https://github.com/python/cpython/commit/b0358e8784821867ab05b3d890717c37309be849


--

___
Python tracker 

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



[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Andrew Svetlov

Change by Andrew Svetlov :


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



[issue32284] typing.TextIO and BinaryIO are not aliases of IO[...]

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Done

--

___
Python tracker 

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



[issue31643] test_uuid: test_getnode and test_windll_getnode fail if connected to the Internet via an Android phone

2017-12-13 Thread Xavier de Gaye

Xavier de Gaye  added the comment:

> C:\> ipconfig -all

So the all-zero MAC address occurs on a Windows box and that explains the 
test_windll_getnode failure (this test is skipped on Android). I missed that 
point in your initial post and knowing what Android device you are using is 
irrelevant.

--

___
Python tracker 

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



[issue32299] unittest.mock.patch.dict.__enter__ should return the dict

2017-12-13 Thread Vadim Tsander

Change by Vadim Tsander :


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

___
Python tracker 

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



[issue32301] Typo in array documentation

2017-12-13 Thread Maik Ro

New submission from Maik Ro :

.. class:: array(typecode[, initializer])

should be 

typecode, [initializer] - comma is in square brackets

--
assignee: docs@python
components: Documentation
messages: 308195
nosy: Maik Ro, docs@python
priority: normal
severity: normal
status: open
title: Typo in array documentation
type: enhancement

___
Python tracker 

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



[issue29465] Modify _PyObject_FastCall() to reduce stack consumption

2017-12-13 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests:  -25

___
Python tracker 

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



[issue32292] Building fails on Windows

2017-12-13 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> It shouldn't be any different, but what about PCBuild/build.bat?

Yes, same thing.

--

___
Python tracker 

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



[issue32301] Typo in array documentation

2017-12-13 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

The given version is correct: the comma is only required if the initializer is 
given. Your suggested version 

typecode, [initializer]

implies that the comma is always required whether the initializer is given or 
not.

If we want to be absolutely pedantic, we could write:

.. class:: array(typecode[, [initializer]])

as trailing commas are legal in function calls. But I don't think that makes 
for good documentation.

--
nosy: +steven.daprano
resolution:  -> rejected
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



[issue29240] PEP 540: Add a new UTF-8 mode

2017-12-13 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 91106cd9ff2f321c0f60fbaa09fd46c80aa5c266 by Victor Stinner in 
branch 'master':
bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)
https://github.com/python/cpython/commit/91106cd9ff2f321c0f60fbaa09fd46c80aa5c266


--

___
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-13 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

For your current situation, list(os.environ) or iter(os.environ) both return 
keys only.

It looks like the __repr__ on the class for os.environ is printed for 
os.environ (which is expected).  For os.environ.keys(), the same __repr__ is 
wrapped as a KeysView, for os.environ.values(), it's wrapped as a ValuesView, 
and os.environ.items(), as an ItemsView.

In 2.7, os.environ.keys() print just keys.

--
nosy: +csabella
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



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

2017-12-13 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
components: +Library (Lib)
type:  -> behavior

___
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-13 Thread R. David Murray

R. David Murray  added the comment:

This is a consequence of the repr used by KeysView, which it inherits from 
MappingView.  I agree that the result is surprising, but there may not be a 
generic fix.  It's not entirely clear what KeysView should do here, but 
presumably we could at least add a repr to environ's use of it that would 
produce something useful.

Note that a workaround when doing something like a travis debug is to print 
os.environ._data.keys(), which will print the bytes versions of the keys.  I 
wouldn't recommend depending on that continuing to, though ;)

--
nosy: +r.david.murray, rhettinger, vstinner -csabella
type: behavior -> 
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



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

2017-12-13 Thread R. David Murray

Change by R. David Murray :


--
nosy: +csabella

___
Python tracker 

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



[issue29240] PEP 540: Add a new UTF-8 mode

2017-12-13 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4727
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-13 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4728

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

Serhiy Storchaka  added the comment:

Wow, 28 PRs for a single issue! This is a record.

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

> Wow, 28 PRs for a single issue! This is a record.

You can expect much more :-) One of the goal of the PEP 432 is to put compute 
sys.path and put it in _PyMainInterpreterConfig. I'm trying to implement that, 
but we are still far from being able to do it. At least, we are getting closer 
at each commit.

While it might be possible to squash 28 changes into a single change, I 
wouldn't be able to review it (I review my own changes on GitHub :-)), and it 
would very annoying if it causes any regression :-(

--

___
Python tracker 

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



[issue31554] Warn when __loader__ != __spec__.loader

2017-12-13 Thread Barry A. Warsaw

Change by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue21762] update the import machinery to only use __spec__

2017-12-13 Thread Barry A. Warsaw

Change by Barry A. Warsaw :


--
nosy: +barry

___
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-13 Thread STINNER Victor

New submission from STINNER Victor :

Example: https://ci.appveyor.com/project/python/cpython/build/3.7.0a0.9414

==
ERROR: test_get_exe_bytes 
(distutils.tests.test_bdist_wininst.BuildWinInstTestCase)
--
Traceback (most recent call last):
  File "C:\projects\cpython\lib\distutils\tests\test_bdist_wininst.py", line 
24, in test_get_exe_bytes
exe_file = cmd.get_exe_bytes()
  File "C:\projects\cpython\lib\distutils\command\bdist_wininst.py", line 361, 
in get_exe_bytes
f = open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 
'C:\\projects\\cpython\\lib\\distutils\\command\\wininst-14.12.exe'
--

--
components: Tests
messages: 308203
nosy: vstinner
priority: normal
severity: normal
status: open
title: test_distutils: test_get_exe_bytes() failure on AppVeyor
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



[issue32303] Namespace packages have inconsistent __loader__ and __spec__.loader

2017-12-13 Thread Barry A. Warsaw

New submission from Barry A. Warsaw :

Let's say I have a namespace package:

>>> importlib_resources.tests.data03.namespace


This package has a non-None __loader__ but a None __spec__.loader:

>>> importlib_resources.tests.data03.namespace.__loader__
<_frozen_importlib_external._NamespaceLoader object at 0x1043c1588>
>>> importlib_resources.tests.data03.namespace.__spec__.loader
>>> 

That seems inconsistent and broken.  I suspect it's just an oversight that the 
__spec__.loader for a namespace package isn't getting set.  It's probably been 
this way forever.

See also Issue31554

--
messages: 308204
nosy: barry
priority: normal
severity: normal
status: open
title: Namespace packages have inconsistent __loader__ and __spec__.loader
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



[issue32304] Upload failed (400): Digests do not match on .tar.gz ending with x0d binary code

2017-12-13 Thread Louis Lecaroz

New submission from Louis Lecaroz :

Hi,
.tar.gz files can end with x0d bytes or whatever you want

When running setup.py sdist upload, depending on the project, the .tar.gz file, 
as said can sometimes end with x0d. When doing the upload, the line 
https://github.com/python/cpython/blob/master/Lib/distutils/command/upload.py#L162
 (if value and value[-1:] == b'\r') will remove the ending char of the .tar.gz 
generating a 400 response error from the server like: 

Upload failed (400): Digests do not match, found: 
09f23b52764a6802a87dd753009c2d3d, expected: 972b8e9d3dc8cf6ba6b4b1ad5991f013
error: Upload failed (400): Digests do not match, found: 
09f23b52764a6802a87dd753009c2d3d, expected: 972b8e9d3dc8cf6ba6b4b1ad5991f013

As this line is generic & run on all key/values, I clearly understand that this 
check was initially written to eliminate certainly some issues on values in 
text format. 

But the mistake here, is that you are also changing the content of the 
'content' key which contains the .tar.gz as value, and because you remove the 
ending 0D, you change the .tar.gz content to be uploaded. As consequence, the 
server will return a 400 error about a wrong digest/crc.

I was able to make the code working with all .tar.gz files by changing this 
line to:

if value and value[-1:] == '\r' and not key=='content':

With a such fix, the .tar.gz content will not see its ending \r to be removed & 
the computed CRC from the server will be the same as computed by 
md5(content).hexdigest() in upload.py

--
components: Distutils
messages: 308205
nosy: dstufft, eric.araujo, llecaroz
priority: normal
severity: normal
status: open
title: Upload failed (400): Digests do not match on .tar.gz ending with x0d 
binary code
type: security
versions: Python 2.7, Python 3.5, 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



[issue32305] Namespace packages have inconsistent __file__ and __spec__.origin

2017-12-13 Thread Barry A. Warsaw

New submission from Barry A. Warsaw :

Along the lines of Issue32303 there's another inconsistency in namespace 
package metadata.  Let's say I have a namespace package:

>>> importlib_resources.tests.data03.namespace


The package has no __file__ attribute, and it has a misleading __spec__.origin

>>> importlib_resources.tests.data03.namespace.__spec__.origin
'namespace'
>>> importlib_resources.tests.data03.namespace.__file__
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'importlib_resources.tests.data03.namespace' has no 
attribute '__file__'

This is especially bad because the documentation for __spec__.origin implies a 
correlation to __file__, and says:

"Name of the place from which the module is loaded, e.g. “builtin” for built-in 
modules and the filename for modules loaded from source. Normally “origin” 
should be set, but it may be None (the default) which indicates it is 
unspecified."

I don't particularly like that its origin is "namespace".  That's an odd 
special case that's unhelpful to test against (what if you import a 
non-namespace package from the directory "namespace"?)

What would break if __spec__.origin were (missing? or) None?

--
messages: 308206
nosy: barry
priority: normal
severity: normal
status: open
title: Namespace packages have inconsistent __file__ and __spec__.origin
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



[issue32305] Namespace packages have inconsistent __file__ and __spec__.origin

2017-12-13 Thread Eric V. Smith

Change by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue32303] Namespace packages have inconsistent __loader__ and __spec__.loader

2017-12-13 Thread Eric V. Smith

Change by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue31554] Warn when __loader__ != __spec__.loader

2017-12-13 Thread Eric V. Smith

Change by Eric V. Smith :


--
nosy: +eric.smith

___
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-13 Thread Zachary Ware

Change by Zachary Ware :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
priority: normal -> high
stage:  -> needs patch

___
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-13 Thread Steve Dower

Steve Dower  added the comment:

I thought we'd special cased the v14 toolset already.

This should be an update to the Python code in distutils that selects the 
filename based on compiler version.

--

___
Python tracker 

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



[issue32292] Building fails on Windows

2017-12-13 Thread Steve Dower

Steve Dower  added the comment:

Are you using a normal command prompt or the Visual Studio one? Totally clean 
environment should work fine these days, but I suspect there's an environment 
variable affecting something.

"set" to show everything that is set, remove any personal info and post or just 
email it to me if you'd like me to check.

--

___
Python tracker 

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



[issue32292] Building fails on Windows

2017-12-13 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

It's a normal command prompt.  Here is the output of "set":
https://gist.github.com/pitrou/2baf9950b0ab2f68b39b4973355b2e79

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

Extract of pythoninfo of the failed build:

os.environ[VS110COMNTOOLS]: C:\Program Files (x86)\Microsoft Visual Studio 
11.0\Common7\Tools\
os.environ[VS120COMNTOOLS]: C:\Program Files (x86)\Microsoft Visual Studio 
12.0\Common7\Tools\
os.environ[VS140COMNTOOLS]: C:\Program Files (x86)\Microsoft Visual Studio 
14.0\Common7\Tools\

The build starts with:

Using "C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"  (found in the PATH)

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

Oh, and the PATH:

os.environ[PATH]: 
C:\Perl\site\bin;C:\Perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
 Files\7-Zip;C:\Tools\GitVersion;C:\Tools\NuGet;C:\Program Files\Microsoft\Web 
Platform Installer\;C:\Tools\PsTools;C:\Program Files\Git LFS;C:\Program 
Files\Mercurial\;C:\Program Files 
(x86)\Subversion\bin;C:\Tools\WebDriver;C:\Tools\Coverity\bin;C:\Tools\MSpec;C:\Tools\NUnit\bin;C:\Tools\NUnit3;C:\Tools\xUnit;C:\Program
 Files\nodejs;C:\Program Files (x86)\iojs;C:\Program 
Files\iojs;C:\Users\appveyor\AppData\Roaming\npm;C:\Program Files\Microsoft SQL 
Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client 
SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL 
Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL 
Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL 
Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL 
Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\1
 30\Tools\Binn\;C:\Program Files\Microsoft SQL 
Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL 
Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL 
Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client 
SDK\ODBC\130\Tools\Binn\;C:\Ruby193\bin;C:\go\bin;C:\Program 
Files\Java\jdk1.8.0\bin;C:\Program Files 
(x86)\Apache\Maven\bin;C:\Python27;C:\Python27\Scripts;C:\Program 
Files\erl8.3\bin;C:\Program Files (x86)\CMake\bin;C:\Tools\curl\bin;C:\Program 
Files\LLVM\bin;C:\Users\appveyor\.dnx\bin;C:\Program Files\Microsoft 
DNX\Dnvm\;C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\MSBuild\15.0\Bin;C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130;C:\Program 
Files\Amazon\AWSCLI\;C:\Program Files\dotnet\;C:\Tools\vcpkg;C:\Program Files 
(x86)\dotnet\;C:\Users\appveyor\AppData\Local\Microsoft\WindowsApps;C:\Users\appveyor\AppData\Local\Yarn\bin;C:\Users\appveyor\AppData\Roaming\npm;C:\Program
 Files\Docker
 ;C:\Program Files\Git\cmd;C:\Program Files\Microsoft Service 
Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service 
Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program 
Files\Git\usr\bin;C:\Program Files 
(x86)\Yarn\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Microsoft 
SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL 
Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL 
Server\140\DTS\Binn\;C:\Program Files (x86)\nodejs\;C:\Program Files 
(x86)\Microsoft Visual 
Studio\2017\Community\Common7\IDE\Extensions\TestPlatform;C:\Users\appveyor\AppData\Local\Microsoft\WindowsApps;C:\Users\appveyor\AppData\Local\Yarn\bin;C:\Users\appveyor\AppData\Roaming\npm;C:\Program
 Files\AppVeyor\BuildAgent\

--

___
Python tracker 

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



[issue29240] PEP 540: Add a new UTF-8 mode

2017-12-13 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset d5dda98fa80405db82e2eb36ac48671b4c8c0983 by Victor Stinner in 
branch 'master':
pymain_set_sys_argv() now copies argv (#4838)
https://github.com/python/cpython/commit/d5dda98fa80405db82e2eb36ac48671b4c8c0983


--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset d5dda98fa80405db82e2eb36ac48671b4c8c0983 by Victor Stinner in 
branch 'master':
pymain_set_sys_argv() now copies argv (#4838)
https://github.com/python/cpython/commit/d5dda98fa80405db82e2eb36ac48671b4c8c0983


--

___
Python tracker 

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



[issue15873] datetime: add ability to parse RFC 3339 dates and times

2017-12-13 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4729

___
Python tracker 

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



[issue10344] codecs.open() buffering doc needs fix

2017-12-13 Thread Alexey Izbyshev

Change by Alexey Izbyshev :


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



[issue32236] open() shouldn't silently ignore buffering=1 in binary mode

2017-12-13 Thread Alexey Izbyshev

Change by Alexey Izbyshev :


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

___
Python tracker 

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



[issue21332] subprocess bufsize=1 docs are misleading

2017-12-13 Thread Alexey Izbyshev

Change by Alexey Izbyshev :


--
pull_requests: +4732

___
Python tracker 

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



[issue15873] datetime: add ability to parse RFC 3339 dates and times

2017-12-13 Thread Mathieu Dupuy

Mathieu Dupuy  added the comment:

I finally released my work. It looks like Paul's work is more comprehensive, 
but if you want to pick one thing or two in mine, feel free.

--

___
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-13 Thread Steve Dower

Steve Dower  added the comment:

This is the bit that needs fixing 
https://github.com/python/cpython/blob/master/Lib/distutils/command/bdist_wininst.py#L340

bv = '.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2])
if bv == '14.11':
# v141 and v140 are binary compatible,
# so keep using the 14.0 stub.
bv = '14.0'

AppVeyor has clearly gotten hold of 14.12, which should also be binary 
compatible (version numbers here are not strictly SemVer, but the 14 indicates 
binary compatibility).

--

___
Python tracker 

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



[issue30491] Add a lightweight mechanism for detecting un-awaited coroutine objects

2017-12-13 Thread Yury Selivanov

Yury Selivanov  added the comment:

First, I've no questions about the proposed implementation.  It shouldn't have 
performance impact when unawaited coroutine tracking is off, which is the 
default.  It will cause minimal overhead when the tracking is on, which is 
fine.  Adding two extra pointers to coroutine objects should be OK too.

Back to the specification.  Few questions:

1. How will trio handle situations like:

c = coro()
await ...
nursery.start_soon(c)

?

There's a brief period of time when "c" is not being awaited, and thus it will 
be in the list that "sys.collect_unawaited_coroutines()" returns.  How exactly 
do you plan to use this new API in Trio?

Maybe creating a coroutine and not immediately passing it to 'start_soon' or 
similar API is an anti-pattern in Trio, but it is an OK thing to do in 
asyncio/curio/twisted.


2. What if another framework (say asyncio that you want to interoperate with) 
calls "sys.set_unawaited_coroutine_tracking(False)"?  

The API you propose has the *same* pitfall that 'sys.set_coroutine_wrapper()' 
has, when used by several frameworks simultaneously.


3. Given (2), why don't you have a coroutine wrapper like this:

   def trio_coroutine_wrapper(coro):
   ref = weakref.ref(coro, trio._untrack_coro)
   trio._track_coro(ref)
   return coro

This way:

- you don't introduce a lot of overhead, because there's no actual wrapper 
around a coroutine

- you can capture the file/lineno at the point where a coroutine was created, 
which is useful for reporting unawaited coroutines

--

___
Python tracker 

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



[issue29240] PEP 540: Add a new UTF-8 mode

2017-12-13 Thread STINNER Victor

STINNER Victor  added the comment:

test_readline failed. It seems to be related to my commit:

http://buildbot.python.org/all/#/builders/87/builds/360

==
FAIL: test_nonascii (test.test_readline.TestReadline)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/test/test_readline.py",
 line 219, in test_nonascii
self.assertIn(b"text 't\\xeb'\r\n", output)
AssertionError: b"text 't\\xeb'\r\n" not found in 
bytearray(b"^A^B^B^B^B^B^B^B\t\tx\t\r\n[\\303\\257nserted]|t\x07\x08\x08\x08\x08\x08\x08\x08\x07\x07xrted]|t\x08\x08\x08\x08\x08\x08\x08\x07\r\nresult
 \'[\\xefnsexrted]|t\'\r\nhistory \'[\\xefnsexrted]|t\'\r\n")

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

@Steve: do you want to work on a fix?

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

Usually, I use print(sorted(os.environ)) since I prefer a sorted list and it 
prevents such issue :-)

David:
> I agree that the result is surprising, but there may not be a generic fix.

What about something like:

vstinner@apu$ ./python -c 'import os; print(os.environ.keys())'


vstinner@apu$ git diff
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index a5c7bfcda1..5e524dffbf 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -719,6 +719,9 @@ class KeysView(MappingView, Set):
 def __iter__(self):
 yield from self._mapping
 
+def __repr__(self):
+return '' % list(self)
+
 KeysView.register(dict_keys)
 
 

list(key_view) is valid. I mimicked dict views implementation:

static PyObject *
dictview_repr(_PyDictViewObject *dv)
{
PyObject *seq;
PyObject *result;

seq = PySequence_List((PyObject *)dv);
if (seq == NULL)
return NULL;

result = PyUnicode_FromFormat("%s(%R)", Py_TYPE(dv)->tp_name, seq);
Py_DECREF(seq);
return result;
}

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

If we decide to change abc.KeysView.__repr__, IMHO we should also modify 
abc.ValuesView.__repr__, and maybe also abc.ItemsView.__repr__.

--

___
Python tracker 

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



[issue32306] Clarify map API in concurrent.futures

2017-12-13 Thread David Lukeš

New submission from David Lukeš :

The docstring for `concurrent.futures.Executor.map` starts by stating that it 
is "Equivalent to map(func, *iterables)". In the case of Python 3, I would 
argue this is true only superficially: with `map`, the user expects 
memory-efficient processing, i.e. that the entire resulting collection will not 
be held in memory at once unless s/he requests so e.g. with `list(map(...))`. 
(In Python 2, the expectations are different of course.) On the other hand, 
while `Executor.map` superficially returns a generator, which seems to align 
with this expectation, what happens behind the scenes is that the call blocks 
until all results are computed and only then starts yielding them. In other 
words, they have to be stored in memory all at once at some point.

The lower-level multiprocessing module also describes 
`multiprocessing.pool.Pool.map` as "A parallel equivalent of the map() built-in 
function", but at least it immediately goes on to add that "It blocks until the 
result is ready.", which is a clear indication that all of the results will 
have to be stored somewhere before being yielded.

I can think of several ways the situation could be improved, listed here from 
most conservative to most progressive:

1. Add "It blocks until the result is ready." to the docstring of 
`Executor.map` as well, preferably somewhere at the beginning.
2. Reword the docstrings of both `Executor.map` and `Pool.map` so that they 
don't describe the functions as "equivalent" to built-in `map`, which raises 
the wrong expectations. ("Similar to map(...), but blocks until all results are 
collected and only then yields them.")
3. I would argue that the function that can be described as semantically 
equivalent to `map` is actually `Pool.imap`, which yields results as they're 
being computed. It would be really nice if this could be added to the 
higher-level `futures` API, along with `Pool.imap_unordered`. `Executor.map` 
simply doesn't work for very long streams of data.
4. Maybe instead of adding `imap` and `imap_unordered` methods to `Executor`, 
it would be a good idea to change the signature of `Executor.map(func, 
*iterables, timeout=None, chunksize=1)` to `Executor.map(func, *iterables, 
timeout=None, chunksize=1, block=True, ordered=True)`, in order to keep the API 
simple with good defaults while providing flexibility via keyword arguments.
5. I would go so far as to say that for me personally, the `block` argument to 
the version of `Executor.map` proposed in #4 above should be `False` by 
default, because that would make it behave most like built-in `map`, which is 
the least suprising behavior. But I've observed that for smaller work loads, 
`imap` tends to be slower than `map`, so I understand it might be a tradeoff 
between performance and semantics. Still, in a higher-level API meant for 
non-experts, I think semantics should be emphasized.

If the latter options seem much too radical, please consider at least something 
along the lines of #1 above, I think it would help people correct their 
expectations when they first encounter the API :)

--
components: Library (Lib)
messages: 308221
nosy: David Lukeš
priority: normal
severity: normal
status: open
title: Clarify map API in concurrent.futures
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



[issue30491] Add a lightweight mechanism for detecting un-awaited coroutine objects

2017-12-13 Thread Matthias Bussonnier

Matthias Bussonnier  added the comment:

Your last description is about exactly what 
https://github.com/python-trio/trio/pull/176 is about (which I need to resurect)

There are some issue with weakref some that I don't remember, but one of them 
is (IIRC): what if a non-awaited coro get collected before being awaited and 
check by trio ? 

   send_ping() # don't care about result, forgot await
   # get collected
   await something_that_will_trigger_check_coros_weakreaf() # oh no !

   
So if its weak-refd then you can't be sure you are actually preventing 
non-awaited coros.

By default in trio we also would like to enforce immediate coro awaiting, but 
we of course would provide a convenience function to wrap coroutines you really 
do not want to await now. (Explicit is better than implicit) So you would write:

c = coro()
really_not_awaiting_now_leave_me_alone(c)
await ... #
nursery.start_soon(c)

What above PR does is check each time you enter the trio scheduler whether 
there is unawaited Coros (not marked as really_no_not_awaiting_now), and if so, 
next time you restart this task (or enter an cancellation point.. but details) 
raise a NonAwaitedCoroutineError. It does not raise _exactly_ where it was not 
awaited but narrow down where the non-awaited coro is (between two schedule 
point). And _if_ you enable tracemalloc the error message give you where the 
stack trace that created this coro.

--

___
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-13 Thread R. David Murray

R. David Murray  added the comment:

Agreed about the other classes if we change this.  Your solution looks 
reasonable to me.

--

___
Python tracker 

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



[issue30491] Add a lightweight mechanism for detecting un-awaited coroutine objects

2017-12-13 Thread Yury Selivanov

Yury Selivanov  added the comment:

>   send_ping() # don't care about result, forgot await
>   # get collected
>   await something_that_will_trigger_check_coros_weakreaf() # oh no !

I don't understand what you are trying to say with this example.  What is 
"something_that_will_trigger_check_coros_weakreaf" supposed to do?

The point of my proposal that you will have a coroutine reported at the "get 
collected" point in CPython, or sometime later in PyPy.

> So if its weak-refd then you can't be sure you are actually preventing 
> non-awaited coros.

Sorry, I don't understand this sentence either.

--

___
Python tracker 

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



[issue32004] Allow specifying code packing order in audioop adpcm functions

2017-12-13 Thread MosesofEgypt

MosesofEgypt  added the comment:

Added serhiy.storchaka to nosy list as the issue has been open for over a month 
without response(not sure if I should have done this in the first place).

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



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

2017-12-13 Thread Natanael Copa

New submission from Natanael Copa :

Python assumes that the system default thread stack size is big enough for 
python, except for OSX and FreeBSD where stack size is explicitly set. With 
musl libc the system thread stack size is only 80k, which leads to hard crash 
before `sys.getrecursionlimit()` is hit.

See: https://github.com/python/cpython/blob/master/Python/thread_pthread.h#L22


Testcase:

import threading
import sys

def f(n=0):
try:
print(n)
f(n+1)
except Exception:
print("we hit recursion limit")
sys.exit(0)

t = threading.Thread(target=f)
t.start()


This can be pasted into:

  docker run --rm -it python:2.7-alpine
  docker run --rm -it python:3.6-alpine

--
components: Interpreter Core
messages: 308226
nosy: Natanael Copa
priority: normal
severity: normal
status: open
title: Bad assumption on thread stack size makes python crash with musl libc
type: crash
versions: Python 2.7, Python 3.6

___
Python tracker 

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



[issue32236] open() shouldn't silently ignore buffering=1 in binary mode

2017-12-13 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

After looking at the PR, I think it would be a bit too strong to raise an 
error. Perhaps emit a warning instead?

--

___
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-13 Thread R. David Murray

R. David Murray  added the comment:

Well, from our point of view it isn't a bad assumption, it's that muslc needs 
to be added to the list of exceptions.  (I know almost nothing about this...I 
assume there is some reason we can't determine the stack size programatically?)

Would you care to propose a PR?

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



[issue32030] PEP 432: Rewrite Py_Main()

2017-12-13 Thread STINNER Victor

Change by STINNER Victor :


--
pull_requests: +4733

___
Python tracker 

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



[issue32308] Replace empty matches adjacent to a previous non-empty match in re.sub()

2017-12-13 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

Currently re.sub() replaces empty matches only when not adjacent to a previous 
match. This makes it inconsistent with re.findall() and re.finditer() which 
finds empty matches adjacent to a previous non-empty match and with other RE 
engines.

Proposed PR makes all functions that makes repeated searching (re.split(), 
re.sub(), re.findall(), re.finditer()) mutually consistent.

The PR change the behavior of re.split() too, but this doesn't matter, since it 
already is different from the 3.6 behavior.

BDFL have approved this change.

This change doesn't break any stdlib code. It is expected that it will not 
break much third-party code, and even if it will break some code, it can be 
easily rewritten. For example replacing re.sub('(.*)', ...) (which now matches 
an empty string at the end of the string) with re.sub('(.+)', ...) is an 
obvious fix.

--
assignee: serhiy.storchaka
components: Library (Lib), Regular Expressions
messages: 308229
nosy: ezio.melotti, mrabarnett, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Replace empty matches adjacent to a previous non-empty match in re.sub()
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue32308] Replace empty matches adjacent to a previous non-empty match in re.sub()

2017-12-13 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue32292] Building fails on Windows

2017-12-13 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Ok, I've decided to bite the bullet.  I uninstalled VS 2015 and installed VS 
2017 Community Edition.  Things seem to work now.  Thanks for the help!

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



[issue30491] Add a lightweight mechanism for detecting un-awaited coroutine objects

2017-12-13 Thread Matthias Bussonnier

Matthias Bussonnier  added the comment:

Let me try to explain better, I'm pretty sure there is just a misunderstanding
from some of use in the vocabulary or presupposition we start from. I have the
impression that you feel like the API will automatically make coroutine raise
when they are not awaited, while I have the impression that in only provide a
tool for frameworks to detect unawaited coros and raise As soon as possible in
the right place.


We have the scheduler/eventloop that advance users tasks. Each time a user task
yield to the scheduler directly, or indirectly, the scheduler want to check that
since last time it was called in the same task no non-awaited coroutines are
pending, that is to say

await sleep(0) # yield to scheduler
c1 = coro() 
await c1

c2 = coro()

c3 = coro()
del c3
gc.collect()

await sleep(0) # yield again.


We want to make sure that between the two `sleep(0)` no coro is unawaited. Let's
assume `await coro()` does not itself yield to the scheduler for simplicity. In
above case you can see that c2 is not awaited, so according to Nathaniel
proposal, `sys.collect_unawaited_coroutines()` would returns `[c2, c3]`, So the
second sleep(0) can raise NonAwaitedCoroutineError, (and if tracemalloc is
enabled give more informations). 



You propose to use 
  weakref.ref(coro, trio._untrack_coro)

And I suppose you want us to do

  def _untrack_coro(self, ref):
  coro = ref()
  if inspect.getcoroutinestate(c) == 'CORO_STARTED'
.. do what's necessary for unawaited coroutine. 
  else:
# just discard from the tracked list.


Unfortunately:

> the weak reference object will be passed as the only parameter to the
> callback; *the referent will no longer be available*.

Thus we cannot check the state of the collected coroutine, according to my
understanding and experiments (Also we need to keep ref alive, but that's a
minor inconvenience). My guess is the referent is not around for users not to
suddenly add a ref to it...

So such a tracked list could only be use to know if coroutines where GC'd or
not.


If you are using wekrefs, you may also think about
`sys.collect_unawaited_coroutines()` returning weakref list, but that would lead
to `WeakRefList[c2]` because c3 was collected :-(. While we still raise because 
of
c2, a user logic only containing c3 would pass the "no unawaited coroutines".

To respond to your answer more specifically:

> 1. How will trio handle situations like:

>c = coro()
>await ...
>nursery.start_soon(c)


It depends what your `...` is, if its yielding to the trio scheduler, then the
scheduler will check unawaited coroutines, see that the list is non-empty and
raise a NonAwaitedCoroutineError at your `await ...`. In the case your `await
...` does not yield.. then nothing. 

> Maybe creating a coroutine and not immediately passing it to 'start_soon' or 
> similar API is an anti-pattern in Trio, but it is an OK thing to do in 
> asyncio/curio/twisted.

Yes, and the trio/curio/asyncio library is responsible to check
`sys.collect_unawaited_coroutines()`, and react appropriately. Trio will likely
decide to raise. Asyncio can just forget this option exists.

> 2. What if another framework (say asyncio that you want to interoperate with) 
> calls "sys.set_unawaited_coroutine_tracking(False)"?  

> The API you propose has the *same* pitfall that 'sys.set_coroutine_wrapper()' 
> has, when used by several frameworks simultaneously.

As far as I understand you'll need to yield back to the other framework at some
point. Then it's IMHO to the author to make sure to save the state of
`sys.collect_unawaited_coroutines()`, set
`sys.set_unawaited_coroutine_tracking(enabled: bool)` to what the other
framework expect, and  do the opposite when they get control back. 


> 3. Given (2), why don't you have a coroutine wrapper like this:

>  def trio_coroutine_wrapper(coro):
>  ref = weakref.ref(coro, trio._untrack_coro)
>  trio._track_coro(ref)
>  return coro

We can't use weakref (cf issue with c3/weakref above).


We could track all coroutines, with a normal container, which is exactly what we
do here[1], except now everytime you need to check
`inspect.getcoroutinestate(coro) == 'CORO_CREATED'` on every item. You can't
use weakref callback as you can't check the coro state in this case. The check
on all coro everytime does add potentially significant overhead, AND block the
GC of awaited couroutines in between checks. While we _do want_ to  block GC of
coroutine only if `sys.collect_unawaited_coroutines()` is set to true and
coroutine is not awaited.

Also we like to keep the actual non-awaited coro around for error messages, but
I guess we can do without. 

One alternative would be the ability to add a callback when coros change
states... But I though coroutines where one way to avoid callbacks...


Now you have way more understanding of core CPython than me, and I may just not
figure out what you would

[issue32104] add method throw() to asyncio.Task

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

I think the ship has sailed.
Now too many code is based on assumption that the only way to cancel a task 
from outer code is `task.cancel()`. Internally it is turned into 

try:
   await do_stuff()
except asyncio.CancelledError:
   do_task_cancellation() 

Raising *any* exception for cancellation breaks all existing code like this. 
Moreover figuring out if a task was cancelled from outside (by timeout for 
example) or exception was raised by inner code becomes impossible.

I suggest closing the issue with "wont fix" resolution.

--
nosy: +asvetlov

___
Python tracker 

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



[issue31620] asyncio.Queue leaks memory if the queue is empty and consumers poll it frequently

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Sorry for late closing the issue, PR was merged a month ago.

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



[issue32302] test_distutils: test_get_exe_bytes() failure on AppVeyor

2017-12-13 Thread Steve Dower

Steve Dower  added the comment:

Happy for someone else to do it. I won't have time this week - too much going 
on at work.

--

___
Python tracker 

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



[issue26259] Memleak when repeated calls to asyncio.queue.Queue.get is performed, without push to queue.

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Duplicate of https://bugs.python.org/issue31620

--
nosy: +asvetlov
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> asyncio.Queue leaks memory if the queue is empty and consumers 
poll it frequently

___
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-13 Thread Neil Schemenauer

Change by Neil Schemenauer :


--
pull_requests: +4735
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



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

2017-12-13 Thread Neil Schemenauer

Neil Schemenauer  added the comment:

I created a new PR which uses the atexit module instead of using _Py_PyAtExit.  
I think registering in io.py is okay.

I see that atexit is now implemented in C.  Rather than registering in io.py, 
we could create a C API to register callbacks (i.e. atexit_register).  That 
would perhaps be a bit cleaner.

--

___
Python tracker 

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



[issue32296] Implement asyncio._get_running_loop() and get_event_loop() in C

2017-12-13 Thread Yury Selivanov

Yury Selivanov  added the comment:


New changeset a70232f28882d2fecb3ebe06643867701016070f by Yury Selivanov in 
branch 'master':
bpo-32296: Implement asyncio.get_event_loop and _get_running_loop in C. (#4827)
https://github.com/python/cpython/commit/a70232f28882d2fecb3ebe06643867701016070f


--

___
Python tracker 

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



[issue32296] Implement asyncio._get_running_loop() and get_event_loop() in C

2017-12-13 Thread Yury Selivanov

Change by Yury Selivanov :


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

___
Python tracker 

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



[issue32309] Implement asyncio.create_task() and asyncio.run_in_executor shortcuts

2017-12-13 Thread Andrew Svetlov

New submission from Andrew Svetlov :

loop.create_task() and loop.run_in_executor are present very often in user 
code. But they are require a loop instance, actual call looks like

loop = asyncio.get_running_loop()
loop.create_task(coro())

The proposal adds create_task(coro) and run_in_executor(executor, func, *args) 
shortcuts for this.

--
assignee: docs@python
components: Documentation, asyncio
messages: 308238
nosy: asvetlov, docs@python, yselivanov
priority: normal
severity: normal
status: open
title: Implement asyncio.create_task() and asyncio.run_in_executor shortcuts
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



[issue32309] Implement asyncio.create_task() and asyncio.run_in_executor shortcuts

2017-12-13 Thread Andrew Svetlov

Change by Andrew Svetlov :


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

___
Python tracker 

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



[issue32309] Implement asyncio.create_task() and asyncio.run_in_executor shortcuts

2017-12-13 Thread Yury Selivanov

Yury Selivanov  added the comment:

I don't like the low-level API of run_in_executor.  "executor" being the first 
argument, the inability to pass **kwargs, etc.

I'd expect to see a more high-level API, perhaps the one that supports 'async 
with':

async with asyncio.ThreadPool() as pool:
f1 = pool.run(func1)
f2 = pool.run(func2)
r3 = await pool.run(func3)

r1 = f1.result()
r2 = f2.result()
print(r1, r2, r3)

I mean it's great that we can use 'concurrent.futures' in asyncio, but having 
native asyncio pools implementation would be way more convenient to the users.

In any case, can we focus this issue on the "run_in_executor" API, and open a 
new one for "create_task"?

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

Cheryl: would you like to work on a PR? If yes, tests are needed.

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 11a247df88f15b51feff8a3c46005676bb29b96e by Victor Stinner in 
branch 'master':
bpo-32030: Add _PyPathConfig_ComputeArgv0() (#4845)
https://github.com/python/cpython/commit/11a247df88f15b51feff8a3c46005676bb29b96e


--

___
Python tracker 

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



[issue32310] Remove _Py_PyAtExit from Python.h

2017-12-13 Thread Neil Schemenauer

New submission from Neil Schemenauer :

_Py_PyAtExit only supports on callback function.  Its sole use it to be used by 
atexit.  IMHO, it should be removed from Python.h to prevent misuse.

--
components: Interpreter Core
messages: 308242
nosy: nascheme
priority: low
severity: normal
stage: patch review
status: open
title: Remove _Py_PyAtExit from Python.h
type: enhancement

___
Python tracker 

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



[issue32309] Implement asyncio.create_task() and asyncio.run_in_executor shortcuts

2017-12-13 Thread Andrew Svetlov

Change by Andrew Svetlov :


--
assignee: docs@python -> 
nosy:  -docs@python

___
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-13 Thread Andrew Svetlov

Change by Andrew Svetlov :


--
components: Library (Lib), asyncio
nosy: asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Implement asyncio.create_task() shortcut
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



[issue32309] Implement asyncio.run_in_executor shortcut

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Removed create_task() from title

--
title: Implement asyncio.create_task() and asyncio.run_in_executor shortcuts -> 
Implement asyncio.run_in_executor shortcut

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

Serhiy Storchaka  added the comment:

Don't make KeysView.__repr__ and ValuesView.__repr__ containing the lists of 
all keys and values. This will make the repr of the view of a mapping which is 
a proxy of an external DB containing the full content of that DB, which can be 
gigabytes. See for example rejected issue21670.

--
nosy: +serhiy.storchaka

___
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-13 Thread Andrew Svetlov

Change by Andrew Svetlov :


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

___
Python tracker 

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



[issue32310] Remove _Py_PyAtExit from Python.h

2017-12-13 Thread Neil Schemenauer

Change by Neil Schemenauer :


--
keywords: +patch
pull_requests: +4738

___
Python tracker 

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



[issue32309] Implement asyncio.run_in_executor shortcut

2017-12-13 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

https://bugs.python.org/issue32311 opened for create_task()

--

___
Python tracker 

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



[issue32312] Create Py_AtExitRegister C API

2017-12-13 Thread Neil Schemenauer

New submission from Neil Schemenauer :

It would be handy to have a C API that registered an atexit function, similar 
to what calling atexit.register does.  This API could be used by C extension 
modules to register atexit functions.

I think the implementation would be fairly simple.  We need a function that 
calls atexit_register().  The tricky bit is that we need to make sure the 
atexit module has been initialized as atexit_register uses the module state.

This API is different from Py_AtExit in that atexit.register() calls the 
function early in the interpreter shutdown whereas Py_AtExit calls functions 
very late in the shutdown.

--
messages: 308246
nosy: nascheme
priority: low
severity: normal
stage: needs patch
status: open
title: Create Py_AtExitRegister C API
type: enhancement

___
Python tracker 

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



[issue32296] Implement asyncio._get_running_loop() and get_event_loop() in C

2017-12-13 Thread STINNER Victor

STINNER Victor  added the comment:

Hum, sometimes it's better to wait for AppVeyor :-) You broke all Windows 
buildbots! :-) Example:

http://buildbot.python.org/all/#/builders/40/builds/278

==
ERROR: test_get_event_loop_returns_running_loop 
(test.test_asyncio.test_events.TestCGetEventLoop)
--
Traceback (most recent call last):
  File 
"C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_asyncio\test_events.py",
 line 2738, in setUp
watcher = asyncio.SafeChildWatcher()
AttributeError: module 'asyncio' has no attribute 'SafeChildWatcher'
==
ERROR: test_get_event_loop_returns_running_loop 
(test.test_asyncio.test_events.TestPyGetEventLoop)
--
Traceback (most recent call last):
  File 
"C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_asyncio\test_events.py",
 line 2738, in setUp
watcher = asyncio.SafeChildWatcher()
AttributeError: module 'asyncio' has no attribute 'SafeChildWatcher'

--
nosy: +vstinner
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



[issue32312] Create Py_AtExitRegister C API

2017-12-13 Thread STINNER Victor

Change by STINNER Victor :


--
nosy: +pitrou, vstinner

___
Python tracker 

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



[issue32312] Create Py_AtExitRegister C API

2017-12-13 Thread STINNER Victor

STINNER Victor  added the comment:

See also:
[Python-Dev] PEP 489: module m_traverse called with NULL module state
https://mail.python.org/pipermail/python-dev/2017-December/151238.html

--

___
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-13 Thread Aaron Meurer

Aaron Meurer  added the comment:

So the best fix is to just override keys() in the _Environ class, so that it 
returns an EnvironKeysView class that overrides __repr__?

--

___
Python tracker 

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



[issue32312] Create Py_AtExitRegister C API

2017-12-13 Thread Antoine Pitrou

Change by Antoine Pitrou :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32312] Create Py_AtExitRegister C API

2017-12-13 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Calling "atexit.register" using the C API isn't very difficult. The annoying 
part is to wrap a simple C function pointer in a callable PyObject (I don't 
think there is a simple C API for that).

--

___
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

> Don't make KeysView.__repr__ and ValuesView.__repr__ containing the lists of 
> all keys and values. This will make the repr of the view of a mapping which 
> is a proxy of an external DB containing the full content of that DB, which 
> can be gigabytes. See for example rejected issue21670.

The current implementation displays repr(self._mapping):

class MappingView(Sized):
...
def __repr__(self):
return '{0.__class__.__name__}({0._mapping!r})'.format(self)

For your proxy example: what is the proxy? The KeysView subtype, or the mapping?

repr(list), repr(dict) and repr(set) all render their full content in the 
result, no?

repr() on a list of 1 million of items *will* render all items, even if nobody 
wants to read such very long string :-)

If you want to get a smarter __repr__() than the default implementation: just 
override __repr__(), no?

I don't see why KeysView must be special.

--

___
Python tracker 

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



[issue32312] Create Py_AtExitRegister C API

2017-12-13 Thread STINNER Victor

STINNER Victor  added the comment:

Oh by the way, if we decide to add a function, I would prefer to start with a 
private function. The C API is big enough. We can decide in the next version if 
the function becomes useful enough to justify to be added to the public API.

--

___
Python tracker 

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



[issue32296] Implement asyncio._get_running_loop() and get_event_loop() in C

2017-12-13 Thread Yury Selivanov

Change by Yury Selivanov :


--
pull_requests: +4739
stage: resolved -> patch review

___
Python tracker 

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



[issue32296] Implement asyncio._get_running_loop() and get_event_loop() in C

2017-12-13 Thread Yury Selivanov

Yury Selivanov  added the comment:

Thanks Victor.  I've made a PR to fix this.

--

___
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-13 Thread STINNER Victor

Change by STINNER Victor :


--
keywords: +patch
pull_requests: +4740
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-13 Thread STINNER Victor

STINNER Victor  added the comment:

> Happy for someone else to do it. I won't have time this week - too much going 
> on at work.

Sure. I wrote a PR to fix the exact bug.

--

___
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-13 Thread Yury Selivanov

New submission from Yury Selivanov :

There's a fairly extensive discussion here: 
https://github.com/python/asyncio/pull/465

In short, asyncio.run() is a pretty straightforward addition, so let's add it.

The discussion was more focused on the asyncio.run_forever() proposal.  I now 
think that it shouldn't be implemented in asyncio.  Instead we should fix cases 
where 'loop.run_forever' is usually required.  Mainly that's servers, and they 
are easily fixable by making "Server" an async context manager and implementing 
a "server.serve_forever()" method.  That way, with asyncio.run():

async def serve_something():
   async with asyncio.start_server(...) as server:
   await server.serve_forever()

asyncio.run(serve_something())  # No loop.run_forever()!

--
assignee: yselivanov
components: asyncio
messages: 308256
nosy: asvetlov, lukasz.langa, yselivanov
priority: normal
severity: normal
status: open
title: Implement asyncio.run()
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue32313] Wrong inspect.getsource for datetime

2017-12-13 Thread Aaron Meurer

New submission from Aaron Meurer :

inspect.getsource(datetime) shows the Python source code for datetime, even 
when it is the C extension. This is very confusing. 

I believe it's because _datetime is used to override everything in datetime at 
the end of the file (here 
https://github.com/python/cpython/blob/11a247df88f15b51feff8a3c46005676bb29b96e/Lib/datetime.py#L2285),
 but __file__ is not imported.

--
messages: 308255
nosy: Aaron.Meurer
priority: normal
severity: normal
status: open
title: Wrong inspect.getsource for datetime

___
Python tracker 

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



  1   2   >