Skip to content

[3.13] gh-126986: Stop Using _PyInterpreterState_FailIfNotRunning() #127112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down
Loading