summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-03-21 16:49:12 (GMT)
committerGitHub <noreply@github.com>2023-03-21 16:49:12 (GMT)
commit3bb475662ba998e1b2d26fa370794d0804e33927 (patch)
tree47cc612ffac4eb4dda24b4eb51c6796142695ce6 /Python
parent910a64e3013bce821bfac75377cbe88bedf265de (diff)
downloadcpython-3bb475662ba998e1b2d26fa370794d0804e33927.zip
cpython-3bb475662ba998e1b2d26fa370794d0804e33927.tar.gz
cpython-3bb475662ba998e1b2d26fa370794d0804e33927.tar.bz2
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
Diffstat (limited to 'Python')
-rw-r--r--Python/pylifecycle.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 731f340..8b58a14 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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