From 30a89338eb377df08ea8724809101d14612a32eb Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 23 Jun 2020 15:55:45 +0200 Subject: [PATCH] Call _PyWarnings_InitState() in subinterpreters (GH-21078) Py_InitializeFromConfig() now calls also _PyWarnings_InitState() in subinterpreters. --- Python/pylifecycle.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 4bb32abc4be..f0770727f4d 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -685,24 +685,22 @@ pycore_init_import_warnings(PyThreadState *tstate, PyObject *sysmod) return status; } - const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); - if (_Py_IsMainInterpreter(tstate)) { - /* Initialize _warnings. */ - status = _PyWarnings_InitState(tstate); - if (_PyStatus_EXCEPTION(status)) { - return status; - } + /* Initialize _warnings. */ + status = _PyWarnings_InitState(tstate); + if (_PyStatus_EXCEPTION(status)) { + return status; + } - if (config->_install_importlib) { + const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); + if (config->_install_importlib) { + if (_Py_IsMainInterpreter(tstate)) { status = _PyConfig_WritePathConfig(config); if (_PyStatus_EXCEPTION(status)) { return status; } } - } - /* This call sets up builtin and frozen import support */ - if (config->_install_importlib) { + /* This call sets up builtin and frozen import support */ status = init_importlib(tstate, sysmod); if (_PyStatus_EXCEPTION(status)) { return status;