mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
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:
parent
910a64e301
commit
3bb475662b
6 changed files with 27 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue