summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-22 20:54:33 (GMT)
committerGitHub <noreply@github.com>2019-11-22 20:54:33 (GMT)
commit2ec1a1b307cc893adae4662a32e1d2e94b6908e3 (patch)
tree5c29f43b1e5d1fef17d7499744a4c9822e99b31d /Python
parent2582d46fbcf7bdf86b9cf4016850b8d155267ac6 (diff)
downloadcpython-2ec1a1b307cc893adae4662a32e1d2e94b6908e3.zip
cpython-2ec1a1b307cc893adae4662a32e1d2e94b6908e3.tar.gz
cpython-2ec1a1b307cc893adae4662a32e1d2e94b6908e3.tar.bz2
bpo-38858: new_interpreter() uses pycore_init_import_warnings() (GH-17353)
Diffstat (limited to 'Python')
-rw-r--r--Python/pylifecycle.c25
1 files 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;
}