diff --git a/Python/crossinterp.c b/Python/crossinterp.c index 2af0dd6191a..01bb45d23ba 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -985,8 +985,8 @@ _PyXI_ApplyErrorCode(_PyXI_errcode code, PyInterpreterState *interp) break; case _PyXI_ERR_ALREADY_RUNNING: assert(interp != NULL); - assert(_PyInterpreterState_IsRunningMain(interp)); - _PyInterpreterState_FailIfRunningMain(interp); + // In 3.14+ we use _PyErr_SetInterpreterAlreadyRunning(). + PyErr_SetString(PyExc_InterpreterError, "interpreter already running"); break; case _PyXI_ERR_MAIN_NS_FAILURE: PyErr_SetString(PyExc_InterpreterError, diff --git a/Python/pystate.c b/Python/pystate.c index ad3fdce69bf..960895e5bad 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -1053,7 +1053,9 @@ get_main_thread(PyInterpreterState *interp) int _PyInterpreterState_SetRunningMain(PyInterpreterState *interp) { - if (_PyInterpreterState_FailIfRunningMain(interp) < 0) { + if (get_main_thread(interp) != NULL) { + // In 3.14+ we use _PyErr_SetInterpreterAlreadyRunning(). + PyErr_SetString(PyExc_InterpreterError, "interpreter already running"); return -1; } PyThreadState *tstate = current_fast_get(); @@ -1099,6 +1101,7 @@ _PyThreadState_IsRunningMain(PyThreadState *tstate) return get_main_thread(interp) == tstate; } +// This has been removed in 3.14. int _PyInterpreterState_FailIfRunningMain(PyInterpreterState *interp) {