[Python-checkins] Call _PyWarnings_InitState() in subinterpreters (GH-21078)

Victor Stinner webhook-mailer at python.org
Tue Jun 23 09:55:54 EDT 2020


https://github.com/python/cpython/commit/30a89338eb377df08ea8724809101d14612a32eb
commit: 30a89338eb377df08ea8724809101d14612a32eb
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-06-23T15:55:45+02:00
summary:

Call _PyWarnings_InitState() in subinterpreters (GH-21078)

Py_InitializeFromConfig() now calls also _PyWarnings_InitState() in
subinterpreters.

files:
M Python/pylifecycle.c

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 4bb32abc4be1f..f0770727f4de7 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;



More information about the Python-checkins mailing list