Author vstinner
Recipients Charles Bouchard-Légaré, JanVok, Peer Sommerlund, Sandeep, methane, r.david.murray, serhiy.storchaka, smurfix, veky, vinay.sajip, vstinner, yselivanov
Date 2020-10-30.14:32:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1604068339.89.0.187805594311.issue26789@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-10-30 14:32:19vstinnersetrecipients: + vstinner, vinay.sajip, smurfix, r.david.murray, methane, serhiy.storchaka, yselivanov, veky, Peer Sommerlund, JanVok, Charles Bouchard-Légaré, Sandeep
2020-10-30 14:32:19vstinnersetmessageid: <1604068339.89.0.187805594311.issue26789@roundup.psfhosted.org>
2020-10-30 14:32:19vstinnerlinkissue26789 messages
2020-10-30 14:32:19vstinnercreate