STINNER Victor <[email protected]> added the comment:
I hacked logging.FileHandler to keep a reference to the builtin open()
function. I got new problems.
In my test, I got a crash because of an unclosed file. It happens after
PyInterpreterState_Clear(), in finalize_interp_clear():
/* Last explicit GC collection */
_PyGC_CollectNoFail();
setup_context() of Python/_warings.c does crash because tstate->interp->sysdict
is NULL at this point.
Moreover, _io.TextIOWrapper.__init__() fails to import the locale module (to
call locale.getpreferredencoding(), since the encoding is None) and picks the
"ascii" encoding.
Moreover, even if I work around all these issues, _warnings.showwarnings() logs
"lost sys.stderr" into stderr because, again, tstate->interp->sysdict is NULL
at this point (and so sys.stderr no longer exists).
It looks like a bug in finalize_interp_clear() which triggers a garbage
collection, whereas Python is no longer usable.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue26789>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com