gh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig() as Fatal (gh-102657)

Prior to this change, errors in _Py_NewInterpreterFromConfig() were always fatal.  Instead, callers should be able to handle such errors and keep going.  That's what this change supports.  (This was an oversight in the original implementation of _Py_NewInterpreterFromConfig().)  Note that the existing [fatal] behavior of the public Py_NewInterpreter() is preserved.

https://github.com/python/cpython/issues/98608
This commit is contained in:
Eric Snow 2023-03-21 10:49:12 -06:00 committed by GitHub
parent 910a64e301
commit 3bb475662b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 17 deletions

View file

@ -2065,22 +2065,23 @@ error:
return status;
}
PyThreadState *
_Py_NewInterpreterFromConfig(const _PyInterpreterConfig *config)
PyStatus
_Py_NewInterpreterFromConfig(PyThreadState **tstate_p,
const _PyInterpreterConfig *config)
{
PyThreadState *tstate = NULL;
PyStatus status = new_interpreter(&tstate, config);
if (_PyStatus_EXCEPTION(status)) {
Py_ExitStatusException(status);
}
return tstate;
return new_interpreter(tstate_p, config);
}
PyThreadState *
Py_NewInterpreter(void)
{
PyThreadState *tstate = NULL;
const _PyInterpreterConfig config = _PyInterpreterConfig_LEGACY_INIT;
return _Py_NewInterpreterFromConfig(&config);
PyStatus status = _Py_NewInterpreterFromConfig(&tstate, &config);
if (_PyStatus_EXCEPTION(status)) {
Py_ExitStatusException(status);
}
return tstate;
}
/* Delete an interpreter and its last thread. This requires that the