From 2ec1a1b307cc893adae4662a32e1d2e94b6908e3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 22 Nov 2019 21:54:33 +0100 Subject: bpo-38858: new_interpreter() uses pycore_init_import_warnings() (GH-17353) --- Python/pylifecycle.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index e63fb64..cce4783 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -665,15 +665,17 @@ pycore_init_import_warnings(PyThreadState *tstate, PyObject *sysmod) return status; } - /* Initialize _warnings. */ - if (_PyWarnings_Init() == NULL) { - return _PyStatus_ERR("can't initialize warnings"); - } + if (_Py_IsMainInterpreter(tstate)) { + /* Initialize _warnings. */ + if (_PyWarnings_Init() == NULL) { + return _PyStatus_ERR("can't initialize warnings"); + } - if (config->_install_importlib) { - status = _PyConfig_WritePathConfig(config); - if (_PyStatus_EXCEPTION(status)) { - return status; + if (config->_install_importlib) { + status = _PyConfig_WritePathConfig(config); + if (_PyStatus_EXCEPTION(status)) { + return status; + } } } @@ -1575,12 +1577,7 @@ new_interpreter(PyThreadState **tstate_p) goto done; } - status = _PyImportHooks_Init(tstate); - if (_PyStatus_EXCEPTION(status)) { - goto done; - } - - status = init_importlib(tstate, sysmod); + status = pycore_init_import_warnings(tstate, sysmod); if (_PyStatus_EXCEPTION(status)) { goto done; } -- cgit v0.12