Roundup Robot added the comment:
New changeset cd3244416592 by Victor Stinner in branch '3.4':
Issue #22599: Enhance tokenize.open() to be able to call it during Python
https://hg.python.org/cpython/rev/cd3244416592
New changeset 22f2784a276e by Victor Stinner in branch 'default':
(Merge 3.4)
STINNER Victor added the comment:
Yes, please do this.
Ok done. I only added the test to default, not in the 3.4 branch. As Antoine
noticed, the test is fragile, I perfer to not backport it.
Ok, let's focus now on the issue #22696 ;-)
--
dependencies: -Add a function to know about
STINNER Victor added the comment:
Can I apply traceback_at_exit-2.patch? I know that my change on tokenize is not
perfect, but it doesn't look like an hack, and it adds a new unit test.
The linecache module can be enhanced in the issue #22696.
--
Serhiy Storchaka added the comment:
Yes, please do this.
--
versions: +Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22599
___
___
Changes by Serhiy Storchaka storch...@gmail.com:
--
assignee: - haypo
dependencies: +Add a function to know about interpreter shutdown
type: - behavior
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22599
STINNER Victor added the comment:
traceback_at_exit-2.patch: Updated patch to remove import builtins from
tokenize.py, it's no more needed.
Antoine, Serhiy: What do you think about this patch?
IMO the bug is very simple and fixes a common bug.
--
Antoine Pitrou added the comment:
The patch looks fragile to me: who knows whether other similar problems can
appear in other situations?
I would prefer something like traceback_ignore_linecache_error.patch, perhaps
combined with a new function that would tell you whether the interpreter is
Serhiy Storchaka added the comment:
Since I wrote tokenize.open(), I can explain why I chose to import builtins
:-)
Then it is good to me.
I would prefer something like traceback_ignore_linecache_error.patch, perhaps
combined with a new function that would tell you whether the
STINNER Victor added the comment:
The patch looks fragile to me: who knows whether other similar problems can
appear in other situations?
Maybe we can always ignore non fatal errors when calling linecache
from print_exception? Having the Python source code in the traceback
is better, but
STINNER Victor added the comment:
The patch looks fragile to me: who knows whether other similar problems can
appear in other situations?
Oh, I forgot to say that yes, my patch is incomplete, but it is simple
and it is already make the code more reliable.
--
STINNER Victor added the comment:
Oh, I see that Antoine opened the issue #22696.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22599
___
___
STINNER Victor added the comment:
There is one downside of my solution. For now the code uses current builtin
open() which can be overloaded (to handle reading from ZIP archive for
example, or to check permissions).
Oh, does anyone really modify the builtin open() for that? If you already
STINNER Victor added the comment:
traceback_at_exit-2.patch: Updated patch to remove import builtins from
tokenize.py, it's no more needed.
--
Added file: http://bugs.python.org/file36925/traceback_at_exit-2.patch
___
Python tracker
Serhiy Storchaka added the comment:
There is one downside of my solution. For now the code uses current builtin
open() which can be overloaded (to handle reading from ZIP archive for example,
or to check permissions). With my solution it uses builtin open() at the time
of import. I don't know
STINNER Victor added the comment:
Alternative solution of this issue would be to use from builtins import open
as _open instead of import builtins.
Right. I prefer your solution because it's much simpler, it doesn't make
traceback less usable at exit, and it doesn't need to make assumption
New submission from STINNER Victor:
Attached destructortest.py script comes the issue #22480. It calls
traceback.print_exception() at exit. The problem is that the call occurs late
during Python finalization. The object was stored in the namespace of the main
module. Currently, Python deletes
STINNER Victor added the comment:
Errors in the traceback module (caused by linecache) are common when working on
the asyncio module in debug mode. The asyncio tries to log exceptions at exit
to help the debug to track bugs. It uses the garbage collector and destructors
on objects. Example of
Antoine Pitrou added the comment:
There is no patch.
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22599
___
___
Python-bugs-list
STINNER Victor added the comment:
There is no patch.
Oh no :-( I revert all my local changes and I forgot to produce the patch... My
change added a new sys._is_finalizing() function which exposes the private C
variable _Py_Finalizing.
Well, here is a patch which implements the first option
Changes by Martin Panter vadmium...@gmail.com:
--
nosy: +vadmium
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22599
___
___
Python-bugs-list
Serhiy Storchaka added the comment:
Alternative solution of this issue would be to use from builtins import open
as _open instead of import builtins.
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
STINNER Victor added the comment:
See also the issue #19421.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22599
___
___
Python-bugs-list
22 matches
Mail list logo