mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-46417: Clear _io module static objects at exit (GH-30807)
Add _PyIO_Fini() function, called by finalize_interp_clear(). It clears static objects used by the _io extension module.
This commit is contained in:
parent
1626bf4ac7
commit
9c8e490b8f
2 changed files with 99 additions and 44 deletions
|
@ -29,6 +29,8 @@
|
|||
#include "pycore_typeobject.h" // _PyTypes_InitTypes()
|
||||
#include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
|
||||
|
||||
extern void _PyIO_Fini(void);
|
||||
|
||||
#include <locale.h> // setlocale()
|
||||
#include <stdlib.h> // getenv()
|
||||
|
||||
|
@ -1702,6 +1704,10 @@ finalize_interp_clear(PyThreadState *tstate)
|
|||
/* Clear interpreter state and all thread states */
|
||||
_PyInterpreterState_Clear(tstate);
|
||||
|
||||
if (is_main_interp) {
|
||||
_PyIO_Fini();
|
||||
}
|
||||
|
||||
/* Clear all loghooks */
|
||||
/* Both _PySys_Audit function and users still need PyObject, such as tuple.
|
||||
Call _PySys_ClearAuditHooks when PyObject available. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue