mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
gh-94673: Isolate the _io module to Each Interpreter (gh-102663)
Aside from sys and builtins, _io is the only core builtin module that hasn't been ported to multi-phase init. We may do so later (e.g. gh-101948), but in the meantime we must at least take care of the module's static types properly. (This came up while working on gh-101660.) https://github.com/python/cpython/issues/94673
This commit is contained in:
parent
8d015fa000
commit
e6ecd3e6b4
2 changed files with 41 additions and 13 deletions
|
@ -31,7 +31,8 @@
|
|||
#include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
|
||||
#include "opcode.h"
|
||||
|
||||
extern void _PyIO_Fini(void);
|
||||
extern PyStatus _PyIO_InitTypes(PyInterpreterState *interp);
|
||||
extern void _PyIO_FiniTypes(PyInterpreterState *interp);
|
||||
|
||||
#include <locale.h> // setlocale()
|
||||
#include <stdlib.h> // getenv()
|
||||
|
@ -697,6 +698,11 @@ pycore_init_types(PyInterpreterState *interp)
|
|||
return _PyStatus_ERR("failed to initialize an exception type");
|
||||
}
|
||||
|
||||
status = _PyIO_InitTypes(interp);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = _PyExc_InitGlobalObjects(interp);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
|
@ -1700,9 +1706,7 @@ finalize_interp_clear(PyThreadState *tstate)
|
|||
/* Clear interpreter state and all thread states */
|
||||
_PyInterpreterState_Clear(tstate);
|
||||
|
||||
if (is_main_interp) {
|
||||
_PyIO_Fini();
|
||||
}
|
||||
_PyIO_FiniTypes(tstate->interp);
|
||||
|
||||
/* Clear all loghooks */
|
||||
/* Both _PySys_Audit function and users still need PyObject, such as tuple.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue