bpo-38858: new_interpreter() uses pycore_init_import_warnings() (GH-17353)

This commit is contained in:
Victor Stinner 2019-11-22 21:54:33 +01:00 committed by GitHub
parent 2582d46fbc
commit 2ec1a1b307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 14 deletions

View File

@ -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;
}