[issue36430] A possible reference leak in itertools.count()

2019-03-25 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue36430] A possible reference leak in itertools.count()

2019-03-25 Thread Zackery Spytz


New submission from Zackery Spytz :

"long_step" is leaked in itertools_count_impl() if the type->tp_alloc() call 
fails.

--
components: Extension Modules
messages: 338853
nosy: ZackerySpytz
priority: normal
severity: normal
status: open
title: A possible reference leak in itertools.count()
versions: Python 2.7, 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



[issue22189] collections.UserString missing some str methods

2019-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Orivej Desh, would you care to make PR to fix this (and add a test)?

--
priority: low -> 
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



[issue36429] Fix starting IDLE with pyshell

2019-03-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

One can start IDLE from python with import idlelib.idle or import 
idlelib.__main__ but not by importing pyshell, as there is alread a __main__ 
module.  I cannot think of anything else to check.

--

___
Python tracker 

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



[issue36429] Fix starting IDLE with pyshell

2019-03-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


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



[issue22189] collections.UserString missing some str methods

2019-03-25 Thread Orivej Desh


Orivej Desh  added the comment:

collections.UserString.__rmod__ references an undefined variable `args`:

def __rmod__(self, format):
return self.__class__(format % args)

https://github.com/python/cpython/commit/573b44c18f69307d7dbc95c950aab57ef7ea303e#diff-8a750c700ae5ac1d0a14922de83e99ccR1109

--
nosy: +orivej

___
Python tracker 

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



[issue36426] exec() issue when used inside function

2019-03-25 Thread Steve Dower


Steve Dower  added the comment:

This is currently by design, which means 3.8 is likely the only viable place it 
can change. It's also not Windows specific so I removed that component (people 
may remove themselves from nosy).

But +Nick, since I know he has some interest in making locals() behave more 
consistently. Currently it's basically a read-only proxy, as locals are 
optimized within functions which is why you can't see updates via the duct.

--
components:  -Windows
nosy: +ncoghlan
versions: +Python 3.8, Python 3.9 -Python 2.7, 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



[issue36429] Fix starting IDLE with pyshell

2019-03-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The shell actually 'starts', but with an empty box and no prompt.

I am thinking of eventually deprecating and disabling starting with pyshell, 
but until we do, it should work.  If nothing else, we should be able to display 
a deprecation notice if that becomes appropriate.

The lack of reports does suggest that most affected people either switched to 
an approved method or another IDE.

--

___
Python tracker 

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



[issue36429] Fix starting IDLE with pyshell

2019-03-25 Thread Terry J. Reedy


New submission from Terry J. Reedy :

python -m idlelib.pyshell  # and
python f:/dev/3x/lib/idlelib/pyshell.py  # for instance
no longer start IDLE properly.  The separate subprocess startup command for 
when pyshell is the main, from 2004, is obsolete and no longer needed.  The 
command needed is the same as for when IDLE is started otherwise.  It works 
with either method of starting IDLE with pyshell.

In addition, two modules are created from pyshell.py, with names '__main__' and 
'idlelib.pyshell'.  The attempt to prevent this should be at the top of the 
file instead of the bottem and now needs to add 'idlelib.pyshell' instead of 
'pyshell'.  The test for this was to (temporarily) add 'print('running')' at 
the top of the file and see if 'running\n' is printed to the terminal once or 
twice.

An automated test might be done as follows:
1. Move imports in main(), including that of 'testing', to top of file.
2. Add, for instance, 'if testing: print('running') after the import.
3. Mock main().
4. Use test.support for 'with : run pyshell.py'.
5. Check captured stdout for exactly one 'running' occurrence.

--
assignee: terry.reedy
components: IDLE
messages: 338847
nosy: cheryl.sabella, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Fix starting IDLE with pyshell
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



[issue34632] Port importlib_metadata to Python 3.8

2019-03-25 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
pull_requests: +12496

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 20004959d23d07ac784eef51ecb161012180faa8 by Victor Stinner in 
branch 'master':
bpo-36301: Remove _PyCoreConfig.preconfig (GH-12546)
https://github.com/python/cpython/commit/20004959d23d07ac784eef51ecb161012180faa8


--

___
Python tracker 

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



[issue36426] exec() issue when used inside function

2019-03-25 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

But I confirmed the behavior reported


uhmm weird

--

___
Python tracker 

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



[issue36426] exec() issue when used inside function

2019-03-25 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

I test on 3.5 and 3.8 running not in an func and I don't have the problem:

Python 3.8.0a2+ (heads/bpo-36287:ba8f342623, Mar 25 2019, 21:57:16) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'bar'
>>> b = 42
>>> c  = a + ' = c'
>>> c
'bar = c'
>>> exec(c)
>>> 'bar' in locals()
True
>>> print(locals()['bar'])
bar = c
>>> print(bar)
bar = c
>>> print("'bar' OK:", bar)
'bar' OK: bar = c

--
nosy: +eamanu

___
Python tracker 

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



[issue34616] implement "Async exec"

2019-03-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue36428] Support AutoAwait?

2019-03-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Oh, you're right. Thanks! Closing in favor of issue34616.

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



[issue36428] Support AutoAwait?

2019-03-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
superseder:  -> implement "Async exec"

___
Python tracker 

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



[issue36428] Support AutoAwait?

2019-03-25 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I think this is same as issue34616 . The issue talks about the workarounds 
IPython has to use for the feature and links to the PR where it was implemented 
https://github.com/ipython/ipython/pull/11265 . I never knew about this feature 
and this will be very helpful to have especially it reduces boilerplate in 
having async functions for await calls though asyncio.run improved setting up 
loop part. Helps in playing around with API in repl during learning with top 
level await expressions allowed in repl.

--
nosy: +xtreak

___
Python tracker 

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



[issue36428] Support AutoAwait?

2019-03-25 Thread Yury Selivanov


Yury Selivanov  added the comment:

Absolutely. I think there's another open issue for this and I even have a dev 
branch somewhere with this idea half implemented.  Definitely something to have 
in 3.8.

--

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +12495

___
Python tracker 

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



[issue36428] Support AutoAwait?

2019-03-25 Thread Guido van Rossum


New submission from Guido van Rossum :

I just found out about IPython's autoawait feature:
https://ipython.readthedocs.io/en/stable/interactive/autoawait.html

I wonder if we should at least help them do this right in Python 3.8 by having 
a flag to compile() that allows `await` in the toplevel syntax? It looks like a 
relatively small change would suffice to make compiler_visit_expr1() in 
Python/compile.c accept (and generate correct code for) Await_kind outside 
async functions, if some flag is set.

--
components: Interpreter Core, asyncio
messages: 338840
nosy: asvetlov, gvanrossum, yselivanov
priority: normal
severity: normal
status: open
title: Support AutoAwait?
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



[issue36174] Remove licenseUrl field from nuget packages

2019-03-25 Thread Ned Deily


Ned Deily  added the comment:


New changeset 276dcc8cfbb012c932d86d2af60e1797b22b2d1c by Ned Deily (Miss 
Islington (bot)) in branch '3.7':
bpo-36174: Update nuget authoring for new license field. (GH-12300)
https://github.com/python/cpython/commit/276dcc8cfbb012c932d86d2af60e1797b22b2d1c


--
nosy: +ned.deily

___
Python tracker 

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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread Cheryl Sabella


Change by Cheryl Sabella :


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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Thanks for the report and the PR, Andrés!

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f78a5e9ce8f32a195f5f788aade79578437f30a6 by Victor Stinner in 
branch 'master':
bpo-36301: Add _Py_GetEnv() function (GH-12542)
https://github.com/python/cpython/commit/f78a5e9ce8f32a195f5f788aade79578437f30a6


--

___
Python tracker 

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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread miss-islington


miss-islington  added the comment:


New changeset b23b08623a46cef841038ee32948020692ef1b35 by Miss Islington (bot) 
in branch '3.7':
bpo-34085: Improve wording on classmethod/staticmethod (GH-8228)
https://github.com/python/cpython/commit/b23b08623a46cef841038ee32948020692ef1b35


--

___
Python tracker 

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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread miss-islington


miss-islington  added the comment:


New changeset bd96393cda54044d81054225dcfc1b26374589a8 by Miss Islington (bot) 
in branch '2.7':
bpo-34085: Improve wording on classmethod/staticmethod (GH-8228)
https://github.com/python/cpython/commit/bd96393cda54044d81054225dcfc1b26374589a8


--
nosy: +miss-islington

___
Python tracker 

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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12493

___
Python tracker 

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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread Cheryl Sabella


Cheryl Sabella  added the comment:


New changeset 548cb6060ab9d5a66931ea2be4da08c2c72c9176 by Cheryl Sabella (Andre 
Delfino) in branch 'master':
bpo-34085: Improve wording on classmethod/staticmethod (#8228)
https://github.com/python/cpython/commit/548cb6060ab9d5a66931ea2be4da08c2c72c9176


--
nosy: +cheryl.sabella

___
Python tracker 

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



[issue34085] doc Improve wording on classmethod/staticmethod

2019-03-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12494

___
Python tracker 

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



[issue36345] Deprecate Tools/scripts/serve.py in favour of python -m http.server -d

2019-03-25 Thread Brett Cannon

Brett Cannon  added the comment:


New changeset 360e1e4c519cfc139de707bcdd1e6c871eec79ee by Brett Cannon 
(Stéphane Wirtel) in branch 'master':
bpo-36345: Add a new example in the documentation of wsgiref (#12511)
https://github.com/python/cpython/commit/360e1e4c519cfc139de707bcdd1e6c871eec79ee


--

___
Python tracker 

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



[issue34098] multiprocessing.Server swallows original exception traceback

2019-03-25 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
nosy: +davin, pitrou

___
Python tracker 

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



[issue36416] bytes.rpartition bug in online documentation

2019-03-25 Thread PEW's Corner


Change by PEW's Corner :


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

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Right. It was just a general comment :-)
Yep, daemon threads are evil :)

--

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Well, given that this happens as well in Python3.7 and before, at least we 
> should document it and we can think about changing it in the future. But for 
> now, but I suggest keeping both PRs separated (in case we really want to 
> change anything).

Right. It was just a general comment :-)

--

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> I really dislike the design of daemon threads. If it would be only me, I 
> would prefer this nasty feature causing so much issues at Python shutdown.

Well, given that this happens as well in Python3.7 and before, at least we 
should document it and we can think about changing it in the future. But for 
now, but I suggest keeping both PRs separated (in case we really want to change 
anything).

--

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +12491

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1075d1684ab84dc7c28d93cfb46e95e70d3b6d3b by Victor Stinner in 
branch 'master':
bpo-36301: Add _Py_GetConfigsAsDict() function (GH-12540)
https://github.com/python/cpython/commit/1075d1684ab84dc7c28d93cfb46e95e70d3b6d3b


--

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

> This behaviour that protects against problems due to daemon threads 
> registered with the interpreter can be *very* surprising for C-extensions 
> that are using these functions to implement callbacks that can call into 
> Python.

I really dislike the design of daemon threads. If it would be only me, I would 
prefer this nasty feature causing so much issues at Python shutdown.

--

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

> if (_Py_IsFinalizing() && !_Py_CURRENTLY_FINALIZING(tstate))

_Py_IsFinalizing() check is redundant :-)

--

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue36427] Document that PyEval_RestoreThread and PyGILState_Ensure can terminate the calling thread

2019-03-25 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

Currently PyEval_RestoreThread and its callers (mainly PyGILState_Ensure) can 
terminate the thread if the interpreter is finalizing:

PyEval_RestoreThread(PyThreadState *tstate)
{
if (tstate == NULL)
Py_FatalError("PyEval_RestoreThread: NULL tstate");
assert(gil_created());

int err = errno;
take_gil(tstate);
/* _Py_Finalizing is protected by the GIL */
if (_Py_IsFinalizing() && !_Py_CURRENTLY_FINALIZING(tstate)) {
drop_gil(tstate);
PyThread_exit_thread();
Py_UNREACHABLE();
}
errno = err;

PyThreadState_Swap(tstate);
}

This behaviour that protects against problems due to daemon threads registered 
with the interpreter can be *very* surprising for C-extensions that are using 
these functions to implement callbacks that can call into Python. These 
callbacks threads are not owned by the interpreter and are usually joined by 
someone else, ending in deadlocks in many situations.

I propose to add a warning to the documentation to inform users about this 
situation.

--
components: Interpreter Core
messages: 338826
nosy: eric.snow, pablogsal, pitrou, vstinner
priority: normal
severity: normal
status: open
title: Document that PyEval_RestoreThread and PyGILState_Ensure can terminate 
the calling thread
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



[issue36143] Auto-generate Lib/keyword.py

2019-03-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue36143] Auto-generate Lib/keyword.py

2019-03-25 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 91759d98015e1d6d5e1367cff60592ab548e7806 by Pablo Galindo in 
branch 'master':
bpo-36143: Regenerate Lib/keyword.py from the Grammar and Tokens file using 
pgen (GH-12456)
https://github.com/python/cpython/commit/91759d98015e1d6d5e1367cff60592ab548e7806


--
nosy: +pablogsal

___
Python tracker 

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



[issue36370] Check for PyErr_Occurred() after PyImport_GetModule().

2019-03-25 Thread Stefan Krah


Stefan Krah  added the comment:

It looks like 3.6 is in security-fix only mode, so it cannot be backported 
there.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.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



[issue36370] Check for PyErr_Occurred() after PyImport_GetModule().

2019-03-25 Thread Stefan Krah


Stefan Krah  added the comment:


New changeset cdd8d4d6dd57f4c9429566706009d4613277d391 by Stefan Krah (Miss 
Islington (bot)) in branch '3.7':
bpo-36370: Check for PyErr_Occurred() after PyImport_GetModule() (GH-12504)
https://github.com/python/cpython/commit/cdd8d4d6dd57f4c9429566706009d4613277d391


--

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +12489

___
Python tracker 

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



[issue36370] Check for PyErr_Occurred() after PyImport_GetModule().

2019-03-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12488

___
Python tracker 

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



[issue36370] Check for PyErr_Occurred() after PyImport_GetModule().

2019-03-25 Thread Stefan Krah


Stefan Krah  added the comment:


New changeset 027b09c5a13aac9e14a3b43bb385298d549c3833 by Stefan Krah in branch 
'master':
bpo-36370: Check for PyErr_Occurred() after PyImport_GetModule() (GH-12504)
https://github.com/python/cpython/commit/027b09c5a13aac9e14a3b43bb385298d549c3833


--

___
Python tracker 

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



[issue36326] Teach inpsect.getdoc() to read __slots__ with an optional data dictionary

2019-03-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue36326] Teach inpsect.getdoc() to read __slots__ with an optional data dictionary

2019-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset d1e768a67707bf7bb426c1537e1a764e89eaff78 by Raymond Hettinger in 
branch 'master':
bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)
https://github.com/python/cpython/commit/d1e768a67707bf7bb426c1537e1a764e89eaff78


--

___
Python tracker 

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



[issue36408] Tkinter multi-processing performance, Linux 10-25 times faster than Windows 10

2019-03-25 Thread J.E.McCormack


J.E.McCormack  added the comment:

I can run four independent processes (i.e. not using multiprocessing, with no 
links at all between them) yet the results show that only one core is running. 
Where is this lock taking place? Why would a tkinter process need to know about 
another tkinter process?

A little bit of history I have learned is that prior to Windows 7, the GDI 
sub-system imposed a global lock system-wide so that only one process (one 
thread) could write to the display at one time. This meant in effect it was a 
one-core GUI desktop. From Windows 7, this was supposed to have been 'fixed', 
but all I have read is that the "GDI lock became more fine-grained, reducing 
concurrency bottlenecks". I wonder did anyone ever measure performance in 
real-world scenarios to demonstrate whether there was in fact any improvement?

--

___
Python tracker 

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



[issue36424] Pickle fails on frozen dataclass that has slots

2019-03-25 Thread Eric V. Smith


Change by Eric V. Smith :


--
assignee:  -> eric.smith

___
Python tracker 

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



[issue33725] Python crashes on macOS after fork with no exec

2019-03-25 Thread Łukasz Langa

Łukasz Langa  added the comment:

It's trivial but not safe in the sense that code that previously depended on 
some global state setup done in the master process right before fork will stop 
working. If this code is a library that is not in your control, you might not 
be able to "just revert" to fork mode easily.

And that change should be made for every platform so it will affect a much 
broader group of users than are affected by *this* issue.

Another thing is that some application packagers (at least Facebook's XAR but 
probably many others) don't work with "start" by default.

So don't take this lightly, just as Davin is saying. That being said, it's 
probably wise to change the default to "start" which is a better method. And if 
we *are* changing, doing it sooner rather than later makes the most sense.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue36205] Python 3.7 and 3.8 process_time is not reported correctly when built on older macOS versions

2019-03-25 Thread Łukasz Langa

Łukasz Langa  added the comment:

Looks like this will have to be broken for 3.8.0a3, too. I will mark this as a 
release blocker for a4 though.

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue36425] Add Simplified Chinese to the language switcher

2019-03-25 Thread Rohit travels and tours


Change by Rohit travels and tours :


--
type:  -> resource usage

___
Python tracker 

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



[issue36404] Document PendingDeprecationWarning as deprecated

2019-03-25 Thread Brett Cannon


Change by Brett Cannon :


--
nosy: +brett.cannon

___
Python tracker 

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



[issue36298] Lib/pyclbr.py crashes when the package spec cannot be determined by importlib

2019-03-25 Thread Brett Cannon


Brett Cannon  added the comment:

Thanks, mental!

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



[issue36228] Support coercion of complex to float/int

2019-03-25 Thread Mark Dickinson


Mark Dickinson  added the comment:

@nagayev I applaud your enthusiasm here, but multiple core developers have 
already rejected your suggestions in this discussion. Given that, it would 
probably not be a great use of your time to pursue this.

Maybe you could take a look around the bug tracker for other possible issues 
you might be interested in pursuing instead?

If you did wanted to pursue this issue[*] in spite of the discussion above (who 
knows: maybe the core devs who responded on this issue are all misguided, or 
maybe we're all missing an obvious use case), your best bet would be to bring 
it up for wider discussion on the python-ideas mailing list.

[*] There are really two issues in this discussion, not one: there's one about 
`__float__` and `__int__` for complex numbers, and one for extending `floor` 
and `ceil` to complex numbers, but my understanding of the discussion is that 
both those have been rejected at this point.

--

___
Python tracker 

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



[issue36424] Pickle fails on frozen dataclass that has slots

2019-03-25 Thread Jacques Gaudin


Change by Jacques Gaudin :


--
nosy: +jagaudin

___
Python tracker 

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



[issue31369] re.RegexFlag is not included in __all__, makes type inference less useful

2019-03-25 Thread Ethan Furman


Ethan Furman  added the comment:

I see no reason no prefix `RegexFlag` with an `_`.

As far as adding it to `__all__` -- I didn't originally because I was trying to 
mirror the original implementation, but I am not against it.  I would defer 
that decision to those that work on typing.

--
assignee: docs@python -> 
components:  -Documentation
nosy: +gvanrossum, levkivskyi
title: re.RegexFlag is not included in __all__ -> re.RegexFlag is not included 
in __all__, makes type inference less useful

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a6fbc4e25e1dc7d1c9a26888b9115bc6c2afc101 by Victor Stinner in 
branch 'master':
bpo-36301: Add _Py_PreInitializeFromConfig() (GH-12536)
https://github.com/python/cpython/commit/a6fbc4e25e1dc7d1c9a26888b9115bc6c2afc101


--

___
Python tracker 

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



[issue36425] Add Simplified Chinese to the language switcher

2019-03-25 Thread Shengjing Zhu


Change by Shengjing Zhu :


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

___
Python tracker 

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



[issue36426] exec() issue when used inside function

2019-03-25 Thread Domen Jurkovič

Domen Jurkovič  added the comment:

Seems like I don't know how to write a code here. 
Anyway, issue created on stack overflow can be found on:
https://stackoverflow.com/questions/55239875/python-exec-function-broken-in-versions-above-2-7-error-name-not-defined/5524?noredirect=1#comment97362021_5524

Works on 2.7, fails on everything above 3.x

--

___
Python tracker 

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



[issue36426] exec() issue when used inside function

2019-03-25 Thread Domen Jurkovič

New submission from Domen Jurkovič :

I've reported a stack overflow question and no reasonable explation was 
offered. Here is what I've discovered:
.. code-block:: python
def func():
varName = 'bar'
varValue = 42
localVarToEvaluate = varName + ' = varValue'

try:
exec(localVarToEvaluate)
except Exception as err:
print(str(err))

if 'bar' in locals():
# print(locals()['bar']) # (1) OK
# print(bar)  # (2) ERR
#print("'bar' OK:", bar)  # (3) ERR
pass # uncomment any line above

func()

After ``exec()`` is executed, ``bar`` can be seen in ``locals()``, but not 
accessible by intereter. Also, It can be accessed by directly calling 
``print(locals()['bar'](``, but not ``print(bar)``.

This is the problem as long as the code is wrapped in function. If the same 
code is placed in the module body, works as expected. 

Is there any exaplanation for such behaviour, or is this a bug?

--
components: Interpreter Core, Windows
messages: 338812
nosy: paul.moore, schperplata, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: exec() issue when used inside function
type: behavior
versions: Python 2.7, 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



[issue36425] Add Simplified Chinese to the language switcher

2019-03-25 Thread Shengjing Zhu


New submission from Shengjing Zhu :

Just checked on transifex, the Simplified Chinese translation has reached

- 100% of bugs.html
- 100% of tutorial
- 100% of library/functions (builtins)

So, let's add it to the language switcher

{
'zh-cn': 'Simplified Chinese'
}

And backport it to 3.7 branch.

--
assignee: docs@python
components: Documentation
messages: 338811
nosy: docs@python, mdk, xiang.zhang, zhsj
priority: normal
severity: normal
status: open
title: Add Simplified Chinese to the language switcher
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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +12486

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

Note for myself: is there a problem between the priority of PYTHONHOME env var 
and pybuilddir.txt configuration file?

--

___
Python tracker 

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



[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f72346c47537657a287a862305f65eb5d7594fbf by Victor Stinner in 
branch 'master':
bpo-36301: Cleanup preconfig code (GH-12535)
https://github.com/python/cpython/commit/f72346c47537657a287a862305f65eb5d7594fbf


--

___
Python tracker 

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



[issue36408] Tkinter multi-processing performance, Linux 10-25 times faster than Windows 10

2019-03-25 Thread Steve Dower


Steve Dower  added the comment:

Windows only allows a single thread to access Win32 GUI elements at a time, and 
I'm fairly sure whichever part of Tcl/Tk/Tkinter is responsible for this makes 
sure it happens.

So if you're throwing lots of UI updates at the UI thread, then yeah, you're 
going to cause massive contention there. Not sure there's any way around it 
other than "don't do that" - while you *could* lock individual data structures, 
Windows doesn't permit that because it turns out people get it wrong and make 
programs that crash.

--

___
Python tracker 

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



[issue35473] Intel compiler (icc) does not fully support C11 Features, including atomics

2019-03-25 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Perhaps an alternative solution would be to provide conditional definitions for 
the stuff ICC leaves out? I'm assuming ICC can actually handle _Atomic 
uintptr_t if you type it out, it's just missing the typedef for it for whatever 
reason?

--
nosy: +josh.r

___
Python tracker 

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



[issue36422] tempfile.TemporaryDirectory() removes entire directory tree even if it's a mount-point

2019-03-25 Thread Riccardo Murri


Riccardo Murri  added the comment:

> you should be handling errors properly in the first place,
> e.g. by changing your mount_sshfs manager to:
>
> @contextmanager
> def mount_sshfs(localdir, remote):
> subprocess.run(f"sshfs {remote} {localdir}")
> try:
> yield
> finally:
> subprocess.run(f"fusermount -u {localdir}", check=True)
>
> so it actually performed the guaranteed cleanup you expected from it.

This would fix the case where errors occur in the "yield" part of the
`mount_sshfs` context manager, but would not protect from errors *in
the `fusermount -u` call itself*: if `fusermount -u` fails and throws
an exception, the entire mounted filesystem will be erased.

I would contend that, in general, `TemporaryDirectory.cleanup()`
should stop at filesystem boundaries and not descend filesystems
mounted in the temporary directory tree (whether the mount has been
done via a context manager as in the example above or by any other
means is irrelevant).

--

___
Python tracker 

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



[issue36424] Pickle fails on frozen dataclass that has slots

2019-03-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +eric.smith

___
Python tracker 

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



[issue36408] Tkinter multi-processing performance, Linux 10-25 times faster than Windows 10

2019-03-25 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Could you provide a minimal reproducer script? With multiprocessing involved, 
I'd suspect some issue with data sharing (Windows can't fork after all, so it's 
possible something is involved there).

I see nothing obvious in the _tkinter module that would explain this, which 
leaves Tk itself or multiprocess communications as the likely cause; a repro 
script would at least guide investigation.

--
nosy: +josh.r

___
Python tracker 

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



[issue36422] tempfile.TemporaryDirectory() removes entire directory tree even if it's a mount-point

2019-03-25 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Allowing delete_on_error=False is kind of defeating the purpose here; the whole 
point of the with statement is guaranteed, consistent cleanup in both normal 
and error cases. If you knew enough to know you needed to pass delete_on_error, 
you'd also know enough to know you should be handling errors properly in the 
first place, e.g. by changing your mount_sshfs manager to:

@contextmanager
def mount_sshfs(localdir, remote):
subprocess.run(f"sshfs {remote} {localdir}")
try:
yield
finally:
subprocess.run(f"fusermount -u {localdir}", check=True)

so it actually performed the guaranteed cleanup you expected from it.

I don't see anything wrong with adding a delete=True argument to 
TemporaryDirectory, though I'm not seeing it as being as useful as it is with 
TemporaryFile (since the "rewrite file to tempfile, atomic replace old file 
with new file" pattern for updating a file safely doesn't transfer directly to 
directories, where atomic renames aren't an option).

It just seems like your fundamental problem is code that doesn't properly 
handle failure, and I don't think the solution is to make TemporaryDirectory 
handle failure badly as well.

--
nosy: +josh.r

___
Python tracker 

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



[issue36424] Pickle fails on frozen dataclass that has slots

2019-03-25 Thread David Hagen


New submission from David Hagen :

If a dataclass is `frozen` and has `__slots__`, then unpickling an instance of 
it fails because the default behavior is to use `setattr` which `frozen` does 
not allow.

```
import pickle
from dataclasses import dataclass

@dataclass(frozen=True)
class A:
  __slots__ = ('a',)
  a: int

b = pickle.dumps(A(5))
pickle.loads(b)
```

```
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field 'a'
```

This has a straightforward workaround, namely to use `object.setattr`.

```
import pickle
from dataclasses import dataclass

@dataclass(frozen=True)
class A:
__slots__ = ('a',)
a: int

def __getstate__(self):
return dict(
(slot, getattr(self, slot))
for slot in self.__slots__
if hasattr(self, slot)
)

def __setstate__(self, state):
for slot, value in state.items():
object.__setattr__(self, slot, value)


b = pickle.dumps(A(5))
pickle.loads(b)
```

It would be nice if this was fixed for all frozen, slotted dataclasses.

Originally report on SO: 
https://stackoverflow.com/questions/55307017/pickle-a-frozen-dataclass-that-has-slots

--
messages: 338803
nosy: drhagen
priority: normal
severity: normal
status: open
title: Pickle fails on frozen dataclass that has slots
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



[issue2771] Test issue

2019-03-25 Thread Ernest W. Durbin III


Ernest W. Durbin III  added the comment:

Test Notification

--

___
Python tracker 

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



[issue36421] A possible double decref in _ctypes.c's PyCArrayType_new()

2019-03-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 0516f81828887a8ec34a3d5ed342dd396f367dcd by Serhiy Storchaka 
(Zackery Spytz) in branch '2.7':
[2.7] bpo-36421: Fix ref counting bugs in _ctypes.c's PyCArrayType_new(). 
(GH-12534)
https://github.com/python/cpython/commit/0516f81828887a8ec34a3d5ed342dd396f367dcd


--

___
Python tracker 

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



[issue36423] www.pythontest.net is down

2019-03-25 Thread STINNER Victor


STINNER Victor  added the comment:

The server is back. No idea what happened...

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



[issue36423] www.pythontest.net is down

2019-03-25 Thread STINNER Victor


New submission from STINNER Victor :

https://buildbot.python.org/all/#/builders/96/builds/361

Re-running failed tests in verbose mode
Re-running test 'test_urllib2net' in verbose mode
ERROR: test_fileno (test.test_urllib2net.OtherNetworkTests)
ERROR: test_close (test.test_urllib2net.CloseSocketTest)
ERROR: test_ftp_default_timeout (test.test_urllib2net.TimeoutTest)
ERROR: test_ftp_no_timeout (test.test_urllib2net.TimeoutTest)
ERROR: test_ftp_timeout (test.test_urllib2net.TimeoutTest)

--

$ ping www.pythontest.net -c 1
PING www.pythontest.net (159.89.235.38) 56(84) bytes of data.
^C
--- www.pythontest.net ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

--
components: Tests
messages: 338801
nosy: vstinner
priority: normal
severity: normal
status: open
title: www.pythontest.net is down
versions: Python 2.7, 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



[issue2771] Test issue

2019-03-25 Thread Ernest W. Durbin III


Ernest W. Durbin III  added the comment:

Test Email Notification

--

___
Python tracker 

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



[issue36421] A possible double decref in _ctypes.c's PyCArrayType_new()

2019-03-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue19495] context manager for measuring duration of blocks of code

2019-03-25 Thread Caleb Hattingh

Caleb Hattingh  added the comment:

Somehow I missed that there's been an open issue on this. Like others I've 
written a bunch of different incarnations of an "elapsed" context manager over 
the years.  Always for the more crude "how long did this take" reason like 
David mentioned, never the microbenchmarks scenario that timeit serves. The 
work is never quite substantial enough to make a Pypi package of it, but always 
annoying to have to do again the next time the need arises. 


The overall least fiddly scheme I've found is to just use a callback. It's the 
simplest option:


@contextmanager
def elapsed(cb: Callable[[float, float], None], counter=time.perf_counter):
t0 = counter()
try:
yield
finally:
t1 = counter()
cb(t0, t1)


The simple case, the one most people want when they just want a quick check of 
elapsed time on a chunk of code, is then quite easy:


with elapsed(lambda t0, t1: print(f'read_excel: {t1 - t0:.2f} s')):
# very large spreadsheet
df = pandas.read_excel(filename, dtype=str)


(I rarely need to use a timer decorator for functions, because the profiler 
tracks function calls. But within the scope of a function it can sometimes be 
difficult to get timing information, particularly if the calls made there are 
into native extensions)

One of the consequences of using a callback strategy is that an additional 
version might be required for async callbacks (I have used these in production 
also):


@asynccontextmanager
async def aioelapsed(acb: Callable[[float, float], Awaitable[None]],
 counter=time.perf_counter):
t0 = counter()
try:
yield
finally:
t1 = counter()
await acb(t0, t1)


So, the interesting thing here is that there is a general form for which an 
"elapsed" function is just a special case:


T = TypeVar('T')


@contextmanager
def sample_before_and_after(cb: Callable[[T, T], None], sample: Callable[[], 
T]):
before = sample()
try:
yield
finally:
after = sample()
cb(before, after)


The version of "elapsed" given further above is just this with kwarg 
sample=time.perf_counter.  So, it might be sufficient to cover the use-case of 
an "elapsed" context manager instead with something like the above instead, 
which is more general. However, I don't actually have any use cases for this 
more general thing above, other than "elapsed", but I thought it was 
interesting.


Whether any of this merits being in the stdlib or not is hard to say. These 
code snippets are all short and easy to write. But I've written them multiple 
times to make "elapsed".


---


Once the "elapsed" abstraction is available, other cool ideas become a little 
bit easier to think about. These would be things that are user code (not be in 
the stdlib), but which can make use of the "elapsed" cm; for example, a clever 
logger for slow code blocks (written a few of these too):


@contextmanager
def slow_code_logging(logger_name, msg, *args, threshold_sec=1.0, **kwargs):
logger = logging.getLogger(logger_name)

if logger.isEnabledFor(logging.INFO):
def cb(t0: float, t1: float) -> None:
dt = t1 - t0
if dt < threshold_sec:
# Change the logger level depending on threshold
logger.debug(msg, dt, *args, **kwargs)
else:
logger.info(msg, dt, *args, **kwargs)

cm = elapsed(cb)
else:
# Logger is not even enabled, do nothing.
cm = nullcontext()

with cm:
yield


with slow_code_logging(__name__, 'Took longer to run than expected: %.4g s'):
...


And a super-hacky timing histogram generator (which would be quite interesting 
to use for measuring latency in network calls, e.g. with asyncio code):


@contextmanager
def histobuilder(counter, bin_size):
def cb(t0, t1):
dt = t1 - t0
bucket = dt - dt % bin_size
counter[bucket, bucket + bin_size] += 1

with elapsed(cb, counter=time.perf_counter_ns):
yield

counter = Counter()

for i in range(100):
with histobuilder(counter, bin_size=int(5e4)):  # 50 us
time.sleep(0.01)  # 10 ms

for (a, b), v in sorted(counter.items(), key=lambda _: _[0][0]):
print(f'{a/1e6:6.2f} ms - {b/1e6:>6.2f} ms: {v:4} ' + '\u2588' * v)


output:


  9.85 ms -   9.90 ms:1 █
  9.90 ms -   9.95 ms:   10 ██
  9.95 ms -  10.00 ms:   17 █
 10.00 ms -  10.05 ms:8 
 10.05 ms -  10.10 ms:   12 
 10.10 ms -  10.15 ms:5 █
 10.15 ms -  10.20 ms:4 
 10.20 ms -  10.25 ms:4 
 10.25 ms -  10.30 ms:6 ██
 10.30 ms -  10.35 ms:9 █
 10.35 ms -  10.40 ms:3 ███
 10.40 ms -  10.45 ms:5 █
 10.45 ms -  10.50 ms:   12 
 10.50 ms -  10.55 ms:3 ███
 10.55 ms -  10.60 ms:1 █


Things like the histogram builder above become (for me) much simpler when 
"elapsed" is just a thing that 

[issue36301] Add _Py_PreInitialize() function

2019-03-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +12485

___
Python tracker 

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



[issue13611] Integrate ElementC14N module into xml.etree package

2019-03-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

References:

Canonical XML Version 2.0 -- https://www.w3.org/TR/xml-c14n2/
Test cases for Canonical XML 2.0 -- https://www.w3.org/TR/xml-c14n2-testcases/

--

___
Python tracker 

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



[issue36422] tempfile.TemporaryDirectory() removes entire directory tree even if it's a mount-point

2019-03-25 Thread Riccardo Murri


New submission from Riccardo Murri :

The behavior of `tempfile.TemporaryDirectory()` is to delete the
temporary directory when done; this behavior cannot be turned off
(there's no `delete=False`like `NamedTemporaryFile` has instead).

However, in case a filesystem has been mounted on the temporary
directory, this can lead to the entire filesystem being removed.

While I agree that it would be responsibility of the programmer to
ensure that anything that has been mounted on the temp dir is
unmounted, the current behavior makes it quite easy to shoot oneself
in the foot.  Consider the following code::

@contextmanager
def mount_sshfs(localdir, remote):
subprocess.run(f"sshfs {remote} {localdir}")
yield
subprocess.run(f"fusermount -u {localdir}", check=True)

with TemporaryDirectory() as tmpdir:
 with mount_sshfs(tmpdir, remote):
  # ... do stuff ...

Now, even if the `fusermount` call fails, cleanup of
`TemporaryDirectory()` will be performed and the remote filesystem
will be erased!

Is there a way this pattern can be prevented or at least mitigated?
Two options that come to mind:

* add a `delete=True/False` option to `TemporaryDirectory` like 
`NamedTemporaryFile` already has
* add a `delete_on_error` option to avoid performing cleanup during error exit 
from a `with:` block

I have seen this happen with Py 3.6 but it's likely there in the entire 3.x 
series since `TemporaryDirectory` was added to stdlib.

Thanks,
Riccardo

--
components: Library (Lib)
messages: 338795
nosy: riccardomurri
priority: normal
severity: normal
status: open
title: tempfile.TemporaryDirectory() removes entire directory tree even if it's 
a mount-point
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



[issue36421] A possible double decref in _ctypes.c's PyCArrayType_new()

2019-03-25 Thread Zackery Spytz


Change by Zackery Spytz :


--
pull_requests: +12484

___
Python tracker 

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



[issue36347] Renaming the constants for the .flags of PyMemberDef

2019-03-25 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

A discussion on the use of enum and deprecation warnings might be useful, 
although there is a significant risk on bike shedding.

I agree that formally deprecating READONLY can lead to uglier code in extension 
that use the value and need to support anything beyond the bleeding edge 
(although the complication isn't that bad: just add a conditional definition of 
PY_READONLY).  I'm personally not to worried about this, and generally prefer 
being more aggressive with adding deprecation warnings.


W.r.t. C++ and enums: that should be ok, especially when using anonymous enums 
that are basically only used to name constants.  

Bitmask with enums can be more problematic when using named enums that are also 
used for variable definitions because C++ compilers are allowed to use the 
minimal variable size that can represent all defined values (that's also a 
problem for the ABI), but it is also possible to use scoped enums to specify 
the size of values.

--

___
Python tracker 

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



[issue36409] plistlib old API should be removed

2019-03-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It was preserved for compatibility with Python 2.7. From PEP 4:

"In order to facilitate writing code that works in both Python 2 & 3 
simultaneously, any module that exists in both Python 3.5 and Python 2.7 will 
not be removed from the standard library until Python 2.7 is no longer 
supported as specified by PEP 373."

3.9 will be the first Python 3 release after the EOL of 2.7.

--

___
Python tracker 

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



[issue36408] Tkinter multi-processing performance, Linux 10-25 times faster than Windows 10

2019-03-25 Thread SilentGhost


Change by SilentGhost :


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

___
Python tracker 

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



[issue36415] [math] Implement pow2 function

2019-03-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue31980. The objections exposed there are applicable to this issue.

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



[issue36421] A possible double decref in _ctypes.c's PyCArrayType_new()

2019-03-25 Thread miss-islington


miss-islington  added the comment:


New changeset fa27870992a7228c8bf378d53649ee22333b69db by Miss Islington (bot) 
in branch '3.7':
bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). 
(GH-12530)
https://github.com/python/cpython/commit/fa27870992a7228c8bf378d53649ee22333b69db


--
nosy: +miss-islington

___
Python tracker 

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



[issue35884] Add variable access benchmark to Tools/Scripts

2019-03-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 68d228f174ceed151200e7e0b44ffc5edd4e0ea2 by Raymond Hettinger 
(Stefan Behnel) in branch 'master':
bpo-35884: Add string-keys-only microbenchmark for dict access to 
var_access_benchmark.py (GH-11905)
https://github.com/python/cpython/commit/68d228f174ceed151200e7e0b44ffc5edd4e0ea2


--

___
Python tracker 

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



[issue36347] Renaming the constants for the .flags of PyMemberDef

2019-03-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am against deprecating READONLY. This will break virtually every third-party 
extension that use it. Many projects are strong about compiler warning and will 
need to rewrite the code that worked for years.

I think that we can add the deprecation warning only after the last version 
that do not have PY_READONLY (3.7) will be no longer supported. I.e. in 3.11 or 
something around.

Also I am not sure about using enums for flags. Would not this cause problems 
on C++?

Since this is an extending of the C API, it would be better to discuss the 
necessary of adding PY_READWRITE on Python-Dev.

--

___
Python tracker 

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



[issue18429] IDLE: Format Paragraph doesn't function with comment blocks

2019-03-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee:  -> terry.reedy
components: +IDLE

___
Python tracker 

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



[issue30348] IDLE: Add test_autocomplete unittests

2019-03-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Followup is #36419.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
title: IDLE: Add test_autocomplete unittest -> IDLE: Add test_autocomplete 
unittests

___
Python tracker 

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



[issue22614] Idle: problem in PyShellEditorWindow.color_breakpoint_text

2019-03-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee:  -> terry.reedy
components: +IDLE

___
Python tracker 

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



[issue18104] Idle: make human-mediated GUI tests usable

2019-03-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
components: +IDLE

___
Python tracker 

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



[issue36421] A possible double decref in _ctypes.c's PyCArrayType_new()

2019-03-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 5e333784f007950f22de44c1ffab5b0c03d6691f by Serhiy Storchaka 
(Zackery Spytz) in branch 'master':
bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). 
(GH-12530)
https://github.com/python/cpython/commit/5e333784f007950f22de44c1ffab5b0c03d6691f


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue36421] A possible double decref in _ctypes.c's PyCArrayType_new()

2019-03-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12483

___
Python tracker 

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



[issue21981] Idle problem

2019-03-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee:  -> terry.reedy
components: +IDLE

___
Python tracker 

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



  1   2   >