[issue34166] Tools/msgfmt.py emits a DeprecationWarning under Python 3.7

2018-07-20 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


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

___
Python tracker 

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



[issue34168] RAM consumption too high using concurrent.futures (Python 3.7 / 3.6 )

2018-07-20 Thread Tim Peters


Tim Peters  added the comment:

Note that you can consume multiple gigabytes of RAM with this simpler program 
too, and for the same reasons:

"""
import concurrent.futures as cf

bucket = range(30_000_000)

def _dns_query(target):
from time import sleep
sleep(0.1)

def run():
with cf.ThreadPoolExecutor(3) as executor:
future_to_element = dict()

for element in bucket:
future = executor.submit(_dns_query, element)
future_to_element[future] = element

for future in cf.as_completed(future_to_element):
elt = future_to_element[future]
print(elt)

run()
"""

The usual way to mediate between producers and consumers that run at very 
different speeds is to use a bounded queue, so that producers block when 
putting new work items on the queue until consumers make progress taking work 
items off.  That's easy enough to do with `multiprocessing` instead, but 
`concurrent.futures` doesn't support that directly.

If you don't mind doing the work in chunks, this straightforward modification 
allows slashing RAM - the smaller CHUNK is, the less RAM is needed, but also 
the more often the code waits for the most recent chunk to finish:

"""
CHUNK = 10_000

...

def chunkify(iterable, chunk=CHUNK):
from itertools import islice
it = iter(iterable)
while True:
piece = list(islice(it, chunk))
if piece:
yield piece
else:
return

def run():
with cf.ThreadPoolExecutor(3) as executor:
for b in chunkify(bucket):
# essentially the original code just indented
future_to_element = dict()
for element in b:
future = executor.submit(_dns_query, element)
future_to_element[future] = element

for future in cf.as_completed(future_to_element):
elt = future_to_element[future]
print(elt)
"""

--

___
Python tracker 

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



[issue34166] Tools/msgfmt.py emits a DeprecationWarning under Python 3.7

2018-07-20 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

I could see some unclosed file handlers as well. The last commit 
(c56894d305211c98882898f237ff54f620520139) was also made in 2013 and I could 
see no tests for tools too.

➜  cpython git:(master) ✗ ./python ./Tools/i18n/msgfmt.py -o django-no-patch.mo 
django.po
./Tools/i18n/msgfmt.py:112: ResourceWarning: unclosed file <_io.BufferedReader 
name='django.po'>
  lines = open(infile, 'rb').readlines()
./Tools/i18n/msgfmt.py:199: DeprecationWarning: tostring() is deprecated. Use 
tobytes() instead.
  output = generate()
./Tools/i18n/msgfmt.py:202: ResourceWarning: unclosed file <_io.BufferedWriter 
name='django-no-patch.mo'>
  open(outfile,"wb").write(output)
➜  cpython git:(bpo34166) ✗ ./python -Werror ./Tools/i18n/msgfmt.py -o 
django-patch.mo django.po

➜  cpython git:(bpo34166) ✗ sha1sum django-patch.mo
ab77140e8638adfdef6d00d6c02cc926f1dc906f  django-patch.mo
➜  cpython git:(bpo34166) ✗ sha1sum django-no-patch.mo
ab77140e8638adfdef6d00d6c02cc926f1dc906f  django-no-patch.mo

I will raise a PR. Attaching a sample .po file from django project used in the 
above command for testing.

Thanks

--
nosy: +xtreak
Added file: https://bugs.python.org/file47706/django.po

___
Python tracker 

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



[issue34115] code.InteractiveConsole.interact() closes stdin

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

There is an important difference between a program saying 'I am done executing' 
and a user saying 'I am done with the interactive session'.  This is especially 
true in an IDE where 'session' can include many editing and shell sessions.

'Stop executing'  happens when execution reaches the end of the file, which 
causes EOFError upon a read attempt.  It can also be done gracefully before the 
end of input with sys.exit(), which raises SystemExit.

In Interactive Python, 'leave session' can be done with SystemExit or the EOF 
control signal, which appears to raise EOFError.  This suggests that quit() and 
exit(), which were added because newbies did not know the proper way to exit, 
should raise EOFError rather than SystemExit.  The fact that 'quit' displays 
'Use quit() or Ctrl-Z plus Return to exit' (EOF on Windows) suggests the same.  
But I need to experiment (another day).

--

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7900

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 06ca3f0c09d017b9d741553818459cca2d5da587 by Serhiy Storchaka in 
branch 'master':
bpo-34136: Make test_do_not_recreate_annotations more reliable. (GH-8364)
https://github.com/python/cpython/commit/06ca3f0c09d017b9d741553818459cca2d5da587


--

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7899

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The 'roughly equivalent' Python code is real code that really runs, and in that 
sense not pseudocode.  itertools is coded in C, which allows optional args with 
no default.  To have optional args when coding in Python, either a default is 
needed or the argument has to be turned into a residual args tuple of length 0 
or 1.  In the former case, 'var is None' should be read as being the equivalent 
of 'var is undefined' in the C code.

In the latter case, the best equivalent, which has its own noise, might be 

def repeat(object, *times):
if not times:
while True:
yield object
elif len(times) == 1:
for i in range(times[0]):
yield object
else:
raise TypeError(f'There can be at most 1 times argument, not 
{len(times)}')

I prefer what we have.

--
nosy: +terry.reedy
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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Sorry for my mistake, yes, I meant Nuitka.

--

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread Guido van Rossum


Guido van Rossum  added the comment:

(Serhiy: I think you meant Nuitka, not numba -- Nuitka is a Python-to-C++ 
compiler, and Kay is its author. Somehow he managed to confuse us all. :-)

I suspect that the way `python3 -m test` runs the tests whose name you pass on 
the command line causes there to be no `__annotations__` global, while the way 
`python3 -m test.test_opcodes` runs its argument causes there to be one.  It 
seems that when a module is run as `__main__` it always is endowed with an 
`__annotations__` global, but when it is an imported module, `__annotations__` 
is only created when there is at least one top-level annotation.

I don't know why the global is always created for a `__main__`, but I suspect 
there's a good reason; the test will have to cope, because I think it should be 
able to run the tests either way.

--

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> we should let users through documentation know that this code is just 
> pseudo-code 

We already modified the docs to specifically say that the provided code is just 
a rough equivalent.

Thanks for the suggestion, but I'm going to decline.  There doesn't seem to be 
a legitimate use case for this.

--
resolution:  -> not a bug
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



[issue34149] Behavior of the min/max with key=None

2018-07-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Repeating my comment on the Github PR, "I'm persuaded by your idea that min(), 
max(), nsmallest(), nlargest(), sorted(), and itertools.groupby() should 
ideally have the same API for key functions. Syncing of those APIs would be a 
minor improvement. As Serhiy pointed out, this does complicate the type 
signature a bit, but that is of small concern giving that the other four 
functions listed have already gone down this path."

--

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Oh, I missed that this issue is about the test from the CPython testsuite. I 
thought it is about the Numba specific tests.

It is strange that this test is passed when run as

./python -m test test_opcodes

but is failed when run as

./python -m test.test_opcodes

or

./python Lib/test/test_opcodes.py

--

___
Python tracker 

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



[issue34154] Tkinter __init__ documentations sometimes missing valid keyword values

2018-07-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

The official Tk documentation is not always correct. OPTIONS attributes in 
tests should contain full lists of supported options, and running tests 
produces warnings for missed options, like: ListboxTest.OPTIONS doesn't contain 
"justify".

--

___
Python tracker 

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



[issue34154] Tkinter __init__ documentations sometimes missing valid keyword values

2018-07-20 Thread Creation Elemental


Creation Elemental  added the comment:

Ah, yes. That is what I meant to say. The doc string printed by help(widget)

--

___
Python tracker 

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



[issue21600] mock.patch.stopall doesn't work with patch.dict

2018-07-20 Thread ppperry


Change by ppperry :


--
title: mock.patch.stopall doesn't work with patch.dict to sys.modules -> 
mock.patch.stopall doesn't work with patch.dict

___
Python tracker 

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



[issue34154] Tkinter __init__ documentations sometimes missing valid keyword values

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

By documentation, you mean the doc string for each widget, which is the basis 
for the help(widget) response.  I checked that there do not seem to be any 
other issues open for the docstrings.  Go ahead.  Use 
https://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm as the reference.

C.E.: if you have a list of missing thing, can you post?  This is normal 
priority.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, serhiy.storchaka, terry.reedy
stage:  -> needs patch
type:  -> behavior
versions: +Python 3.7, Python 3.8

___
Python tracker 

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



[issue34149] Behavior of the min/max with key=None

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

FWIW, the nsmallest/largest key param was added Dec 2, 2004, before 
keyword-only parameters.
https://github.com/python/cpython/commit/4901a1f267e9d632f85054ce8b21ff23bff305e1

--

___
Python tracker 

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



[issue34149] Behavior of the min/max with key=None

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

In 2.x, map(None, 'abc', 'zyz') == [('a', 'z'), ('b', 'y'), ('c', 'z')], but 
with the addition of zip, so that zip('abc', 'xyz') has the same result, we 
deprecated that use of None to mean identity function.

For python-coded functions, a default is needed to make a keyword-only argument 
optional, and preferred over use of *args for making positional arguments 
optional.  Unless I am missing something, a function can special-case 'key is 
identity', to avoid overhead, just as well as it can special-case 'key is 
None'.  So rather than extend 'key=None', to me a kludge, I would rather 
replace it with 'key=identity'.  Both can be accepted during a deprecation 
period.

For instance, after adding identity,

def nsmallest(n, iterable, key=identity):
...
if key is identity or key is None:  # key in (identity, None)
result = min(it, default=sentinel)
...

Since no one need ever write key=None, explicit passing should be rare.  It 
seems to me that the main reason for the type declaration of key to include 
None is so that the def statement itself passes a consistency check with the 
None default.  Once that is changed, most people should be able to use a simple 
callable declaration.  I am considering this for python-ideas.

Since the weekly issues list came out just 10 hours ago, I will not close this 
yet, but I will if still open in couple of days and no coredev objections.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f2626ce6d4136f13a506e34ca8631ff2eab85fd9 by Victor Stinner in 
branch 'master':
bpo-34170: _PyCoreConfig_Read() leaves Py_IsolatedFlag unchanged (GH-8361)
https://github.com/python/cpython/commit/f2626ce6d4136f13a506e34ca8631ff2eab85fd9


--

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

I changed the minimum time from 20 ms to 15 ms in 
test_time.test_process_time(), in Python 3.7 and master branches.

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a7a6eac966dd52db1762c8f455c1e208df36feb4 by Victor Stinner (Miss 
Islington (bot)) in branch '3.7':
bpo-33723: Fix test_time.test_process_time() (GH-8358) (GH-8362)
https://github.com/python/cpython/commit/a7a6eac966dd52db1762c8f455c1e208df36feb4


--

___
Python tracker 

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



[issue34115] code.InteractiveConsole.interact() closes stdin

2018-07-20 Thread Yonatan Zunger


Yonatan Zunger  added the comment:

Or perhaps in an alternate phrasing: The sys.stdin.close behavior makes sense 
if quit is being used inside IDLE, but is very surprising from the perspective 
of the `code` module. (Really, even the SystemExit is surprising there, and 
should be documented!)

What if we added a stdin-preserving workaround to 
code.InteractiveConsole.interact, and added documentation of the SystemExit 
behavior to that module as well, but left _Quitter itself as-is?

--

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-07-20 Thread miss-islington


Change by miss-islington :


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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset e78dace8dcb23c371df19c9add65895adf436995 by Victor Stinner in 
branch 'master':
bpo-33723: Fix test_time.test_process_time() (GH-8358)
https://github.com/python/cpython/commit/e78dace8dcb23c371df19c9add65895adf436995


--

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +7896

___
Python tracker 

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



[issue34115] code.InteractiveConsole.interact() closes stdin

2018-07-20 Thread Yonatan Zunger


Yonatan Zunger  added the comment:

Testing your code sample on OS X (10.13.6) with Python 3.6.2:

- quit() in the console yields

Exc 0: closed is True
Python 3.6.2 (default, Apr 17 2018, 12:29:33) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> Traceback (most recent call last):
  File "./test.py", line 6, in 
code.InteractiveConsole().interact()
  File "/Users/zunger/.pyenv/versions/3.6.2/lib/python3.6/code.py", line 228, 
in interact
line = self.raw_input(prompt)
  File "/Users/zunger/.pyenv/versions/3.6.2/lib/python3.6/code.py", line 275, 
in raw_input
return input(prompt)
ValueError: I/O operation on closed file.

- ^D and raise SystemExit in console both yield:

Python 3.6.2 (default, Apr 17 2018, 12:29:33) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> ^D
now exiting InteractiveConsole...
Try 0: closed is False
Python 3.6.2 (default, Apr 17 2018, 12:29:33) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> ^D
now exiting InteractiveConsole...
Try 1: closed is False


So it looks like the issue is specific to quit(), as you say. I'm not sure I 
understand what the purpose of the sys.stdin.close() call is, though: why would 
we *want* to alert the parent shell in some way beyond a SystemExit as the 
default (non-overrideable) behavior? This may be a documentation issue, but it 
seems extremely surprising to me; no other function does this additional thing, 
even when raising a SystemExit. I would think that any caller which is running 
InteractiveConsole.interact() and also wants to do something when it finishes 
would want to handle that additional logic itself.

--

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Dong-hee Na


Dong-hee Na  added the comment:

Raymond, when I first read this issue, it seemed very clear that it should not 
work. However, after reading the documentation I misunderstood that it can be 
worked because the pseudocode specifies NoneType. 

IMHO, in that case, we should let users through documentation know that this 
code is just pseudo-code and that the actual counts parameter should be passed 
as an integer type.

--

___
Python tracker 

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



[issue34132] Obscure netrc parser "bug"

2018-07-20 Thread bbayles


bbayles  added the comment:

I realized that the Python 2 solution was adapt-able after all; I've 
re-submitted as GitHub PR 8360.

https://github.com/python/cpython/pull/8360

--

___
Python tracker 

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



[issue34132] Obscure netrc parser "bug"

2018-07-20 Thread bbayles


Change by bbayles :


--
pull_requests: +7895

___
Python tracker 

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



[issue34127] Gramatically incorrect error message for some calls with wrong number of arguments

2018-07-20 Thread ppperry


ppperry  added the comment:

Another test case: 

>> classmethod()

Traceback (most recent call last):
  File "", line 2, in check
TypeError: classmethod expected 1 arguments, got 0

--
title: Gramatically incorrect error message for some descriptor calls with 
wrong number of arguments -> Gramatically incorrect error message for some 
calls with wrong number of arguments

___
Python tracker 

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



[issue33129] Add kwarg-only option to dataclass

2018-07-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

+1 from me -- think would occasionally be nice to have.

--
nosy: +rhettinger

___
Python tracker 

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



[issue34136] Del on class __annotations__ regressed, failing test

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Yes, the test should be removed, commented out, skipped, or made to work, 
depending on intentions.  Test first is for private branches.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue34134] multiprocessing memory huge usage

2018-07-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +pitrou

___
Python tracker 

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



[issue34055] IDLE: erroneous 'smart' indents in shell

2018-07-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Of late, I've also encountered two recurring problems along these lines.  At 
some point in the IDLE session, the auto-indents become large and this survives 
a restart-shell.   Another problem is that an extra \n is emitted after every 
result which gives an odd double-spaced effect.  

When added to other existing bugs, this has greatly impaired the usability of 
IDLE for teaching (the tool tips no longer display on the newest mac builds and 
periodically the mouse pointer is mistargeted by 1/4 of the screen until the 
screen is resized, and periodically I encounter cases where pressing any key in 
the interactive session results in pasting the current contents of the keyboard 
on the current entry line).

--
nosy: +rhettinger

___
Python tracker 

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



[issue34127] Gramatically incorrect error message for some descriptor calls with wrong number of arguments

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Yes.  0 things, (1/2 thing), 1 thing, (3/2 things),  2... things is the bugaboo 
of formatting sentences with a number field.  Raymond, will we accept a patch 
for this?

--
nosy: +rhettinger, terry.reedy
stage:  -> needs patch
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



[issue34176] Asyncio StreamReader fails to close Transport

2018-07-20 Thread Jim DeLaHunt


New submission from Jim DeLaHunt :

Asyncio's StreamReaderProtocol[1] often returns True from 
Protocol.eof_received(). This tells the Transport that "closing the transport 
is up to the protocol" [2]. However, StreamReaderProtocol does not call 
Transport.close(). More precisely, StreamReaderProtocol leaves the transport 
interaction to StreamReader. It calls StreamReader.feed_eof()[3]. But 
StreamReader does not call self._transport.close(). It only sets a self._eof 
flag, and awakens any of its functions which were waiting for data. 

The only occurrence of self._transport.close() occurs in StreamWriter[4]. There 
is none in StreamReader or StreamReaderProtocol.

I believe that the fix should be for StreamReader to call 
self._transport.close(). However, it may need to avoid this if 
StreamReaderProtocol._over_ssl is True, and I don't immediately see how it can 
tell this. Also, it may need to wait for anything waiting for self._waiter to 
run, before closing the Transport.
Or, maybe StreamReaderProtocol should not return True from 
Protocol.eof_received().

I discovered this when using a Transport of my own devising, which reads from a 
file instead of from a socket, with asyncio.streams.  The file did not close in 
the unit test. My transport duly called Protocol.eof_received(), but received a 
True in response, so did not close the file.

My workaround will probably be to not believe what Protocol.eof_received() 
tells me, and to close my transport regardless.

[1] Lib/asyncio.streams.StreamReaderProtocol.eof_received, line 259-266.
[2] 19.5.4.2.3. "Streaming protocols" 

[3] Lib/Lib/asyncio.streams.StreamReader.feed_eof, lines 419-421.
[4] Lib/Lib/asyncio.streams.StreamWriter.close, lines 316-317.

All line numbers are as of tag v3.7.0, commit 
1bf9cc509326bc42cd8cb1650eb9bf64550d817e . 

Bug observed in v3.7.0. Not yet investigated in HEAD revision.

--
components: asyncio
messages: 322047
nosy: JDLH, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Asyncio StreamReader fails to close Transport
type: behavior
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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

I reopen the issue since I got a very similar failure of 
test_time.test_process_time() on my laptop: the busy loop took 15.9 ms
whereas the test expects at least 20 ms. I wrote PR 8358 to only require 15 ms 
instead.

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-07-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +7894

___
Python tracker 

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



[issue34175] typing.NamedTuple: type-checking error when "index" used as member

2018-07-20 Thread Guido van Rossum


Guido van Rossum  added the comment:

> Perhaps this report should go on the mypy bug tracker rather than the Python 
> language tracker.

Agreed. It's up to the OP to file an issue there though (hence adding 
@campkeith back to the nosy list).

--
nosy: +campkeith
resolution:  -> third party
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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, I fixed the fontforge bug in 3.7 and master branches. Sorry for the 
regression, but I really didn't expect that anyone would call Py_Main() after 
Py_Initialize() :-) I guess we should be prepared for such hiccup when 
reworking the Python initialization :-)

Nick: Can I close the issue, or do you want to keep it open to change the 
documentation?

--

___
Python tracker 

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



[issue34175] typing.NamedTuple: type-checking error when "index" used as member

2018-07-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> So I suspect this is a bug in the type checker.

Perhaps this report should go on the mypy bug tracker rather than the Python 
language tracker.

--
nosy: +gvanrossum, levkivskyi, rhettinger -campkeith

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Clint, why do you think you need this?

Dong-hee, the pure python code is listed a rough equivalent, not an exact 
equivalent.

--

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 03ec4df67d6b4ce93a2da21db7c84dff8259953f by Victor Stinner (Miss 
Islington (bot)) in branch '3.7':
bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043) (GH-8352)
https://github.com/python/cpython/commit/03ec4df67d6b4ce93a2da21db7c84dff8259953f


--

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b1147e43daeb3c51a63056b489e8d868404d4e22 by Victor Stinner in 
branch 'master':
bpo-34170: Rework _PyCoreConfig_Read() to avoid side effect (GH-8353)
https://github.com/python/cpython/commit/b1147e43daeb3c51a63056b489e8d868404d4e22


--

___
Python tracker 

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



[issue34115] code.InteractiveConsole.interact() closes stdin

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

To investigate your claim about closing sys.stdin, I ran the following on 
Windows 10, mostly with 3.7.0, in both the console and IDLE, using various exit 
methods.

import code
import sys

for i in range(2):
try:
code.InteractiveConsole().interact()
print(f'Try {i}: closed is', sys.stdin.closed)
except SystemExit:
print(f'Exc {i}: closed is', sys.stdin.closed)

^D in IDLE and ^Z+ in console prints 'Try 0/1...False'.
The IC.interact loop catches EOFError and breaks for a normal exit.

'raise SystemExit' and sys.exit() print 'Exc 0/1...False'.

exit() and quit() print 'Exc 0/1...True' on Console.  On Windows Console, 
sys.stdin.close() does not prevent a second interact call.  This might be 
considered a bug.

What OS are you running and what is the result and traceback for the code above?

In IDLE, either function exit causes a 'Kill the running process' popup.  If 
yes, user code execution ceases and the shell window  closes.  If no, 
SystemExit is caught and 'SysExit...False' is printed.  The latter is true 
because sys.stdin.close in the user process is 'sys.shell.close()', and the 
latter does the popup.  The *purpose* of sys.stdin.close is to get the 
attention of shells that intercept SystemExit, so that users can say 'Close 
this now'.  Even so, IDLE asks users first to make sure.

Emulating IDLE in a simplified fashion as follows will negate closure.
import _io
class Stdin(_io.TextIOWrapper):
def close(self): pass
sys.stdin = Stdin()  # To restore, sys.__stdin__ is the original.


---
History of sys.stdin.close:

https://github.com/python/cpython/commit/24cb053b158a3cd63f7be05ac27f47e45bb2f1b3
Site.py, line 236, Mar 9, 2006, George Brandel added Quitter with __call__ 
consisting of 'raise SystemExit(code)'.

https://github.com/python/cpython/commit/d112bc7958151fa17c4ccb27413c43e45b8476fb#diff-f34a16518c608b2ca946d3f5ca0a1942
site.py, line Aug 16, 2006, Kurt Kaiser added the following lines
# Shells like IDLE catch the SystemExit, but listen when their
# stdin wrapper is closed.
try:
sys.stdin.close()
except:
pass

https://github.com/python/cpython/commit/862543aa85249b46649b60da96743b4b14c6c83b#diff-f34a16518c608b2ca946d3f5ca0a1942
site.py, line 250, Christian Heimes replace stdin.close with the following to 
avoid Lib/io.py: RuntimeWarning: Trying to close unclosable fd. (I believe io 
has since been patched to not do this.)
fd = -1
if hasattr(sys.stdin, "fileno"):
fd = sys.stdin.fileno()
if fd != 0:
# Don't close stdin if it wraps fd 0
sys.stdin.close()

https://hg.python.org/cpython/rev/82451c88b3c0, 11 Apr 2013
After discussion on #17585 with Antoine Pitrou and Serhiy Storchaka, Roger 
Serwy reverted the above because it was no longer needed 
---

Your code assumes that sys.stdin has a buffer attribute.  Not necessarily true 
when python is started with pythonw.exe.  With the print removed, it also 
assumes that sys.stdin has file descriptor 0.  Ditto.
---

Possible doc improvements: the exit/quit doc says that closes.
https://docs.python.org/3/library/constants.html#constants-added-by-the-site-module

interact doc mentions catching exceptions and quit/exit issue.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, terry.reedy
stage:  -> needs patch
type: behavior -> enhancement
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue34163] Python latest release 2.7 shows SSL error

2018-07-20 Thread Brett Cannon


Change by Brett Cannon :


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

___
Python tracker 

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



[issue34175] typing.NamedTuple: type-checking error when "index" used as member

2018-07-20 Thread Keith Campbell


New submission from Keith Campbell :

Find the test case below:


from typing import NamedTuple

class Foo(NamedTuple):
alpha: int
index: int


This results in the following error when run through type-checking with mypy:


% mypy --version
mypy 0.620
% mypy go.py
go.py:5: error: Incompatible types in assignment (expression has type "int", 
base class "tuple" defined the type as "Callable[[Tuple[int, ...], Any, int, 
int], int]")


When I instantiate this class in the python interpreter, I have no problem 
accessing the "index" member, so I suspect this is a bug in the type checker.

--
components: Library (Lib)
messages: 322038
nosy: campkeith
priority: normal
severity: normal
status: open
title: typing.NamedTuple: type-checking error when "index" used as member
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



[issue34174] argparse formatter_class issue for RawDescriptionHelpFormatter

2018-07-20 Thread Chris Kessler


Chris Kessler  added the comment:

Thanks for the quick response!
I didnt see it anywhere in the documentation on that page so I assumed it was 
built in with argparse.
Thanks!

--

___
Python tracker 

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



[issue34174] argparse formatter_class issue for RawDescriptionHelpFormatter

2018-07-20 Thread Mariatta Wijaya


Mariatta Wijaya  added the comment:

Thanks for the report.

To make it work, you'll have to import textwrap first.

We don't always add all the necessary imports in our code snippets and 
examples, and we don't need to start adding imports into code examples either. 
So I'm closing this issue.

Thanks again.

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

___
Python tracker 

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



[issue34161] (good first issue) Tutorial 7.1 str.format() code example syntax error

2018-07-20 Thread Mariatta Wijaya


Mariatta Wijaya  added the comment:


New changeset 49abd307d222e6fe85b5175eed6b6f87fc656a8d by Mariatta (Miss 
Islington (bot)) in branch '3.7':
bpo-34161: Remove extra parentheses in output formatting tutorial (GH-8350)
https://github.com/python/cpython/commit/49abd307d222e6fe85b5175eed6b6f87fc656a8d


--

___
Python tracker 

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



[issue34174] argparse formatter_class issue for RawDescriptionHelpFormatter

2018-07-20 Thread Chris Kessler


New submission from Chris Kessler :

In document 
https://docs.python.org/2/library/argparse.html#argparse.RawDescriptionHelpFormatter

this will fail with NameError: global name 'textwrap' is not defiend

>>> parser = argparse.ArgumentParser(
... prog='PROG',
... formatter_class=argparse.RawDescriptionHelpFormatter,
... description=textwrap.dedent('''\
... Please do not mess up this text!
... 
... I have indented it
... exactly the way
... I want it
... '''))

--
assignee: docs@python
components: Documentation
messages: 322034
nosy: ckessler, docs@python
priority: normal
severity: normal
status: open
title: argparse formatter_class issue for RawDescriptionHelpFormatter
type: resource usage
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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-20 Thread Ammar Askar


Ammar Askar  added the comment:

> But then again, if it's solely for our tests, perhaps the best way to 
> approach this is to start a Python thread that periodically runs this command?

I opened up https://github.com/python/cpython/pull/8357 with this strategy, in 
my opinion its a lot nicer and doesn't clutter up _winapi with half baked, 
extremely specialized functions. Its a bit more involved than running a thread, 
details are on the PR.

--

___
Python tracker 

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



[issue5115] Extend subprocess.kill to be able to kill process groups

2018-07-20 Thread Ammar Askar


Change by Ammar Askar :


--
pull_requests: +7893

___
Python tracker 

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



[issue34060] regrtest: log "CPU usage" on Windows

2018-07-20 Thread Ammar Askar


Change by Ammar Askar :


--
pull_requests: +7892

___
Python tracker 

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



[issue34173] [3.7] possible race condition in /usr/lib/python3.7/concurrent/futures/thread.py

2018-07-20 Thread Corey Bryant


New submission from Corey Bryant :

I initially reported this on launchpad at 
https://bugs.launchpad.net/bugs/1782647.

I'm running a test for a project that hangs and requires a Control-C to cancel 
it. The results look like this: https://paste.ubuntu.com/p/SwXsCcghjt/

In narrowing down on this some more, the use of queue.SimpleQueue() seems to 
make the difference that causes the hang. If I switch that back to 
queue.Queue() (which was the case for py3.6) the hang goes away:

- self._work_queue = queue.Queue()
+ self._work_queue = queue.SimpleQueue()

To reproduce with OpenStack designate:

git clone https://github.com/openstack/designate.

Then, update tox.ini with the following:

--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 minversion = 2.0
-envlist = py35,py27,flake8
+envlist = py35,py37,py27,flake8
 skipsdist = True

 [testenv]
@@ -39,6 +39,12 @@ commands =
   {[testenv]commands}
   stestr run '{posargs}'

+[testenv:py37]
+basepython = python3.7
+commands =
+ {[testenv]commands}
+ stestr run 
'designate\.tests\.test_workers\.test_processing\.TestProcessingExecutor\.(test_execute_multiple_tasks)'
+
 [testenv:docs]
 basepython = python3
 deps =


And run: tox -e py37

--
components: Library (Lib)
messages: 322032
nosy: corey.bryant
priority: normal
severity: normal
status: open
title: [3.7] possible race condition in 
/usr/lib/python3.7/concurrent/futures/thread.py
type: behavior
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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Dong-hee Na


Change by Dong-hee Na :


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



[issue25150] 3.5: Include/pyatomic.h is incompatible with OpenMP (compilation of the third-party module fails on Python 3.5)

2018-07-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions: +Python 3.7, Python 3.8 -Python 3.5

___
Python tracker 

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



[issue34168] RAM consumption too high using concurrent.futures (Python 3.7 / 3.6 )

2018-07-20 Thread Tim Peters


Tim Peters  added the comment:

If your `bucket` has 30 million items, then

for element in bucket:
executor.submit(kwargs['function']['name'], element, **kwargs)

is going to create 30 million Future objects (and all the under-the-covers 
objects needed to manage their concurrency) just as fast as the main thread can 
create them.  Nothing in your code waits for anything to finish until after 
they've _all_ been created and queued up under the covers.

So your producer is running vastly faster than your consumers can keep up with. 
 It's the huge backlog of pending work items that consume the RAM.  To slash 
RAM, you need to craft a way to interleave creating new work items with giving 
consumers time to deal with them.

--
nosy: +tim.peters

___
Python tracker 

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



[issue26544] platform.libc_ver() returns incorrect version number

2018-07-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +7891

___
Python tracker 

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



[issue34118] Fix some class entries in 'Built-in Functions'

2018-07-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I will write a PR only touching the collection class entries.

--

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Dong-hee Na


Dong-hee Na  added the comment:

IMHO, this issue should be fixed since
times=None can be passed,
ref: https://docs.python.org/3/library/itertools.html#itertools.repeat

This documentation also shows the equivalent python code,
>From this code, times=None should work but does not work in current 
>implementation.

def repeat(object, times=None):
# repeat(10, 3) --> 10 10 10
if times is None:
while True:
yield object
else:
for i in range(times):
yield object

I've upload PR with this issue.

--
nosy: +corona10

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue34172] multiprocessing.Pool and ThreadPool leak resources after being deleted

2018-07-20 Thread tzickel


New submission from tzickel :

In multiprocessing.Pool documentation it's written "When the pool object is 
garbage collected terminate() will be called immediately.":

https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing.pool.Pool.terminate

A. This does not happen, creating a Pool, deleting it and collecting the 
garbage, does not call terminate.

B. The documentation for Pool itself does not specify it has a context manager 
(but the examples show it).

C. This bug is both in Python 3 & 2.

--
components: Library (Lib)
messages: 322028
nosy: tzickel
priority: normal
severity: normal
status: open
title: multiprocessing.Pool and ThreadPool leak resources after being deleted
type: behavior
versions: Python 2.7, Python 3.7

___
Python tracker 

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



[issue34157] NamedTemporaryFile can leave temporary files behind

2018-07-20 Thread R. David Murray


Change by R. David Murray :


--
resolution: duplicate -> 
stage: resolved -> needs patch
status: closed -> open

___
Python tracker 

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



[issue34157] NamedTemporaryFile can leave temporary files behind

2018-07-20 Thread R. David Murray


R. David Murray  added the comment:

Nick, what Jakub is saying is that 'with' hasn't even gotten involved yet: 
we're still executing the NamedTemporaryFile constructor, so the object hasn't 
been returned for 'with' to operate on yet.  In other words, 
NamedTemporaryFile.__init__ isn't safe against ctl-C when it calls _mkstemp, 
which is obvious by inspection since it isn't inside the try/except.

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



[issue34161] (good first issue) Tutorial 7.1 str.format() code example syntax error

2018-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7889

___
Python tracker 

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



[issue34171] Lib/trace.cover not removed by the clean target

2018-07-20 Thread Matthias Klose


New submission from Matthias Klose :

Lib/trace.cover is not removed by the clean target, and apparently this file is 
always created in the source tree, not in the build tree.  It should be created 
in the build tree, if that's not possible, it should be cleaned in any case.

--
components: Build
messages: 322026
nosy: doko
priority: normal
severity: normal
status: open
title: Lib/trace.cover not removed by the clean target
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue34161] (good first issue) Tutorial 7.1 str.format() code example syntax error

2018-07-20 Thread Mariatta Wijaya


Mariatta Wijaya  added the comment:

Thanks!

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



[issue34011] Default preference not given to venv DLL's

2018-07-20 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 94487d45707772723ef19e86700a40a12743baa1 by Vinay Sajip in branch 
'master':
bpo-34011: Update code copying DLLs and init.tcl into venvs. (GH-8253)
https://github.com/python/cpython/commit/94487d45707772723ef19e86700a40a12743baa1


--

___
Python tracker 

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



[issue32627] Header dependent _uuid build failure on Fedora 27

2018-07-20 Thread Frank Thommen


Change by Frank Thommen :


--
nosy: +fthommen

___
Python tracker 

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



[issue26544] platform.libc_ver() returns incorrect version number

2018-07-20 Thread Matthias Klose


Matthias Klose  added the comment:

a tuple comparison should be good enough

--

___
Python tracker 

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



[issue34028] Python 3.7.0 wont compile with SSL Support 1.1.0 > alledged missing X509_VERIFY_PARAM_set1_host() support

2018-07-20 Thread Frank Thommen


Frank Thommen  added the comment:

The configure script doesn't work with a proper openssl installation either.  
Even though there is a "lib" directory in the directory given to 
--with-openssl=, libssl.so.1.1 isn't found, because there is still a 
"-L/lib" missing in some of the compiler calls.

LDFLAGS="-L/lib" ./configure --with-openssl= is required, which 
seems somehow redundant.  Bug?

--
nosy: +fthommen

___
Python tracker 

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



[issue26544] platform.libc_ver() returns incorrect version number

2018-07-20 Thread Matthias Klose


Matthias Klose  added the comment:

please don't close this yet.  the patch introduces a dependency on the 
distutils package.  I don't see any reason to compare the libc version as a 
python egg version, so please avoid that.

if we need to have a module to compare arbitrary version strings, then we 
should think about adding one in the standard library, but I think that's what 
the packaging module is for.

--
nosy: +doko

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

PR 8353 is the last piece of my long work on Py_Main() to separate code 
*reading* configuration and code *applying* a new configuration. My work on the 
new _PyPathConfig structure, and the PR should finish that work.

Extract of the commit message:

"A new _PyCoreConfig_SetPathConfig() function now recreates the path 
configuration from the core configuration. This function is now called very 
late in _Py_InitializeCore(), just before calling initimport()."

--

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7887

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset fb47bca9ee2d07ce96df94b4e4abafd11826eb01 by Victor Stinner in 
branch 'master':
bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043)
https://github.com/python/cpython/commit/fb47bca9ee2d07ce96df94b4e4abafd11826eb01


--

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-34008: "Do we support calling Py_Main() after Py_Initialize()?".

--

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

I created bpo-34170: "Py_Initialize(): computing path configuration must not 
have side effect (PEP 432)" as a follow-up of this issue.

--

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


Change by STINNER Victor :


--
Removed message: https://bugs.python.org/msg322014

___
Python tracker 

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



[issue21600] mock.patch.stopall doesn't work with patch.dict to sys.modules

2018-07-20 Thread Antoni Szych


Antoni Szych  added the comment:

Hi,

Any chance of getting this resolved 1 year later? :)

BR

--

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

Attached PR reworks _PyCoreConfig_Read() to leave _Py_path_config unchanged: 
*reading* the core configuration must not *modify* the path configuration.

The PR adds _PyCoreConfig.dll_path field.

The change is related to the PEP 432.

--

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue34170] Py_Initialize(): computing path configuration must not have side effect (PEP 432)

2018-07-20 Thread STINNER Victor


New submission from STINNER Victor :

Attached

--
components: Interpreter Core
messages: 322014
nosy: vstinner
priority: normal
severity: normal
status: open
title: Py_Initialize(): computing path configuration must not have side effect 
(PEP 432)
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



[issue34157] NamedTemporaryFile can leave temporary files behind

2018-07-20 Thread Nick Coghlan


Nick Coghlan  added the comment:

It's still the same problem - the underlying issue is that the with statement 
machinery doesn't currently mask signals in the main thread while __enter__ and 
__exit__ are running, so __enter__ and __exit__ methods written in Python are 
also at risk of being interrupted at an inopportune point.

This means that even "with closing(open('filename')) as f: ..." is more at risk 
of leaving the file open until __del__ cleans it up than the version that calls 
open() directly.

So if this a concern that an application needs to worry about, then it 
currently needs to adopt a more complicated execution structure where:

1. The main thread launches a subthread that actually does all the work.
2. The main thread immediately drops into "active_thread.join()" (which can be 
interrupted by Ctrl-C)

Unfortunately, this scheme *doesn't* work for applications where the 
application itself needs to detect and handling signals other than Ctrl-C.

--

___
Python tracker 

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



[issue34164] base64.b32decode() leads into UnboundLocalError and OverflowError on some data

2018-07-20 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Thank you for your report Jussi.

The type "crash" is used for hard crashes of the Python interpreter – possibly 
with a core dump or a Windows error box.

--
nosy: +serhiy.storchaka
type: crash -> behavior
versions: +Python 3.6, Python 3.8

___
Python tracker 

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



[issue34164] base64.b32decode() leads into UnboundLocalError and OverflowError on some data

2018-07-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue34161] (good first issue) Tutorial 7.1 str.format() code example syntax error

2018-07-20 Thread Aaqa Ishtyaq


Change by Aaqa Ishtyaq :


--
pull_requests: +7885

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread Nick Coghlan


Nick Coghlan  added the comment:

+1 from me for the idea of fixing Python 3.7 to correctly set sys.argv in this 
case (and leaving everything else unmodified).

As far as further enhancement in Python 3.8 goes, perhaps that can be seen as 
part of PEP 432, such that embedding applications have to explicitly opt-in to 
any new behaviour by calling the new APIs?

--

___
Python tracker 

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



[issue34169] itertools.repeat does not accept None as an explicit count

2018-07-20 Thread Clint Hepner


New submission from Clint Hepner :

I expected to be able to pass None as an explicit count to itertools.repeat to 
get the default behavior of an infinite iterator:

>>> list(islice(repeat(1), 10))
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
>>> list(islice(repeat(1, None), 10))
Traceback (most recent call last):
  File "", line 1 in 
TypeError: 'NoneType' object cannot be interpreted as an integer

--
components: Library (Lib)
messages: 322010
nosy: chepner
priority: normal
severity: normal
status: open
title: itertools.repeat does not accept None as an explicit count
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



[issue34161] (good first issue) Tutorial 7.1 str.format() code example syntax error

2018-07-20 Thread Aaqa Ishtyaq


Change by Aaqa Ishtyaq :


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



[issue34157] NamedTemporaryFile can leave temporary files behind

2018-07-20 Thread Jakub Wilk


Jakub Wilk  added the comment:

I think issue29988 is unrelated, or at least not the whole story.

These are samples of tracebacks I see when the file is left behind:

  Traceback (most recent call last):
File "test-tmpfile.py", line 4, in 
  with tempfile.NamedTemporaryFile(dir='.'):
File "/opt/python/lib/python3.8/tempfile.py", line 548, in 
NamedTemporaryFile
  (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/opt/python/lib/python3.8/tempfile.py", line 258, in _mkstemp_inner
  fd = _os.open(file, flags, 0o600)
  KeyboardInterrupt
  
  Traceback (most recent call last):
File "test-tmpfile.py", line 4, in 
  with tempfile.NamedTemporaryFile(dir='.'):
File "/opt/python/lib/python3.8/tempfile.py", line 548, in 
NamedTemporaryFile
  (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/opt/python/lib/python3.8/tempfile.py", line 269, in _mkstemp_inner
  return (fd, _os.path.abspath(file))
File "/opt/python/lib/python3.8/posixpath.py", line 371, in abspath
  path = os.fspath(path)
  KeyboardInterrupt
  
  Traceback (most recent call last):
File "test-tmpfile.py", line 4, in 
  with tempfile.NamedTemporaryFile(dir='.'):
File "/opt/python/lib/python3.8/tempfile.py", line 548, in 
NamedTemporaryFile
  (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/opt/python/lib/python3.8/tempfile.py", line 269, in _mkstemp_inner
  return (fd, _os.path.abspath(file))
File "/opt/python/lib/python3.8/posixpath.py", line 378, in abspath
  return normpath(path)
File "/opt/python/lib/python3.8/posixpath.py", line 355, in normpath
  if comp in (empty, dot):
  KeyboardInterrupt

In all cases the interrupt happened in the NamedTemporaryFile function,
so before __enter__/__exit__ would have chance to do its job.

--

___
Python tracker 

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



[issue34154] Tkinter __init__ documentations sometimes missing valid keyword values

2018-07-20 Thread Noah Haasis


Noah Haasis  added the comment:

I'd like to work on this, if it's ok for everybody.

--
nosy: +noah.haasis

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

I looked one more time at Python 3.6, code before my huge 
Py_Main()/Py_Initialize() refactoring, before 
_PyCoreConfig/_PyMainInterpreterConfig have been added. In short, calling 
Py_Main() after Py_Initialize() "works" in Python 3.6 but only sys.argv is set: 
almost all other options are lost/ignored. For example, if you call 
Py_Initialize() you get a sys.path from the current environment, but if 
Py_Main() gets a new module search path: sys.path is not updated.

I modified PR 8043 to write the minimum patch just to fix fontforge. When 
Py_Main() is called Py_Initialize(): just set sys.argv, that's all.

If someone wants to fix this use case, apply properly the new Py_Main() 
configuration carefully, I would suggest to only work in the master branch: 
that's out of the scope of this specific regression.

IMHO it would be nice to enhance this use case. For example, it would be "nice" 
to update at least "sys.path" (and other related variables) in such case.

--

___
Python tracker 

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



[issue34008] Do we support calling Py_Main() after Py_Initialize()?

2018-07-20 Thread STINNER Victor


STINNER Victor  added the comment:

> This hits fontforge. See https://bugzilla.redhat.com/show_bug.cgi?id=1595421

Copy of my comment 20:



I looked one more time to the issue:

* fontforge code is fine: it calls Py_Initialize() before using the Python C 
API to initialize its Python namespace (modules, functions, types, etc.), and 
later it calls Py_Main().

* Python 3.7.0 is wrong: it fails with a fatal erro when Py_Main() is called if 
Py_Initialize() has been called previously. It is a regression since it worked 
fine in Python 3.6.

* My PR https://github.com/python/cpython/pull/8043 works again the simplest 
test: "fontforge -script hello.py" where hello.py is just "print('Hello 
World!')"

* This PR is not enough according to Miro, since fontforge requires sys.argv to 
be set, whereas sys.argv is no longer set when Py_Main() is after 
Py_Initialize(): 
https://github.com/python/cpython/pull/8043#issuecomment-401731992

--

___
Python tracker 

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



[issue34168] RAM consumption too high using concurrent.futures (Python 3.7 / 3.6 )

2018-07-20 Thread Dem


Dem  added the comment:

It seems that even without the as_completed call it has the same problem. 


```
# -*- coding: utf-8 -*-
import dns.resolver
import concurrent.futures
from pprint import pprint
from json import json


bucket = json.load(open('30_million_strings.json','r'))


def _dns_query(target, **kwargs):
global bucket
resolv = dns.resolver.Resolver()
resolv.timeout = kwargs['function']['dns_request_timeout']
try:
resolv.query(target + '.com', kwargs['function']['query_type'])
with open('out.txt', 'a') as f:
f.write(target + '\n')
except Exception:
pass


def run(**kwargs):
global bucket
temp_locals = locals()
pprint({k: v for k, v in temp_locals.items()})

with 
concurrent.futures.ThreadPoolExecutor(max_workers=kwargs['concurrency']['threads'])
 as executor:
for element in bucket:
executor.submit(kwargs['function']['name'], element, **kwargs)


run(function={'name': _dns_query, 'dns_request_timeout': 1, 'query_type': 'MX'},
concurrency={'threads': 15})
```

--

___
Python tracker 

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



[issue34168] RAM consumption too high using concurrent.futures (Python 3.7 / 3.6 )

2018-07-20 Thread Dem


New submission from Dem :

I have a list of 30 million strings, and I want to run a dns query to all of 
them. I do not understand how this operation can get memory intensive. I would 
assume that the threads would exit after the job is done, and there is also a 
timeout of 1 minute as well ({'dns_request_timeout': 1}).

Here is a sneak peek of the machine's resources while running the script:

[![enter image description here][1]][1]

My code is as follows:

# -*- coding: utf-8 -*-
import dns.resolver
import concurrent.futures
from pprint import pprint
from json import json


bucket = json.load(open('30_million_strings.json','r'))


def _dns_query(target, **kwargs):
global bucket
resolv = dns.resolver.Resolver()
resolv.timeout = kwargs['function']['dns_request_timeout']
try:
resolv.query(target + '.com', kwargs['function']['query_type'])
with open('out.txt', 'a') as f:
f.write(target + '\n')
except Exception:
pass


def run(**kwargs):
global bucket
temp_locals = locals()
pprint({k: v for k, v in temp_locals.items()})

with 
concurrent.futures.ThreadPoolExecutor(max_workers=kwargs['concurrency']['threads'])
 as executor:
future_to_element = dict()

for element in bucket:
future = executor.submit(kwargs['function']['name'], element, 
**kwargs)
future_to_element[future] = element

for future in concurrent.futures.as_completed(future_to_element):
result = future_to_element[future]


run(function={'name': _dns_query, 'dns_request_timeout': 1, 'query_type': 
'MX'},
concurrency={'threads': 15})


  [1]: https://i.stack.imgur.com/686SW.png

--
components: Library (Lib)
messages: 322004
nosy: DemGiran
priority: normal
severity: normal
status: open
title: RAM consumption too high using concurrent.futures (Python 3.7 / 3.6 )
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



[issue28166] WindowsConsoleIO misbehavior when Ctrl+C is ignored

2018-07-20 Thread Eryk Sun


Eryk Sun  added the comment:

> all the input before the ignored Ctrl+C is lost

The console host process doesn't know that Python is ignoring Ctrl+C, so it 
cancels the read and flushes the input buffer. For now, we have to accept this 
as a limitation of relying on the high-level console API (i.e. ReadConsoleW 
with the default settings), which implements command-line editing, aliases and 
history completely in the console host process. Restarting the read with a 
flushed input buffer is better than raising EOFError or exiting the REPL.

In the future, Python's console readline implementation could hook deeper into 
the operation by temporarily disabling the console's ENABLE_PROCESSED_INPUT 
mode and using the pInputControl parameter to handle ^C and ^H (backspace). 
This would be fairly involved but still an imperfect solution because ^C will 
replace whichever character is under the cursor (fine if the cursor is at the 
end of the line, but otherwise pretty clunky). The only way to have complete 
control is to use the low-level ReadConsoleInput function. pyreadline 
implements this via ctypes.

--

___
Python tracker 

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



  1   2   >