diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2023-03-21 14:01:38 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-21 14:01:38 -0600 |
commit | e6ecd3e6b437f3056e0a410a57c52e2639b56353 (patch) | |
tree | d4cfb7bcec5fa2abf2c0a98f74baa59c879c9905 /Python/pylifecycle.c | |
parent | 8d015fa000db5775d477cd04dc574ba13721e278 (diff) | |
download | cpython-e6ecd3e6b437f3056e0a410a57c52e2639b56353.tar.gz cpython-e6ecd3e6b437f3056e0a410a57c52e2639b56353.zip |
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
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index d0e85519d23..8110d94ba17 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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. |