diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2024-11-19 00:11:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-19 00:11:12 (GMT) |
commit | d6b3e78504b3168c432b20002dbcf8ec9a435e61 (patch) | |
tree | 80f67fcc0eb7b52b925117e674db1845c870dd62 /Python/pystate.c | |
parent | 0063f5f314350ad5122a86f31df65f5dff4f4e5c (diff) | |
download | cpython-d6b3e78504b3168c432b20002dbcf8ec9a435e61.zip cpython-d6b3e78504b3168c432b20002dbcf8ec9a435e61.tar.gz cpython-d6b3e78504b3168c432b20002dbcf8ec9a435e61.tar.bz2 |
gh-126986: Drop _PyInterpreterState_FailIfNotRunning() (gh-126988)
We replace it with _PyErr_SetInterpreterAlreadyRunning().
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 24ee73c..a209a26 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1047,10 +1047,17 @@ get_main_thread(PyInterpreterState *interp) return _Py_atomic_load_ptr_relaxed(&interp->threads.main); } +void +_PyErr_SetInterpreterAlreadyRunning(void) +{ + PyErr_SetString(PyExc_InterpreterError, "interpreter already running"); +} + int _PyInterpreterState_SetRunningMain(PyInterpreterState *interp) { - if (_PyInterpreterState_FailIfRunningMain(interp) < 0) { + if (get_main_thread(interp) != NULL) { + _PyErr_SetInterpreterAlreadyRunning(); return -1; } PyThreadState *tstate = current_fast_get(); @@ -1096,17 +1103,6 @@ _PyThreadState_IsRunningMain(PyThreadState *tstate) return get_main_thread(interp) == tstate; } -int -_PyInterpreterState_FailIfRunningMain(PyInterpreterState *interp) -{ - if (get_main_thread(interp) != NULL) { - PyErr_SetString(PyExc_InterpreterError, - "interpreter already running"); - return -1; - } - return 0; -} - void _PyInterpreterState_ReinitRunningMain(PyThreadState *tstate) { |