Skip to content

Commit b927efc

Browse files
Do not backport the API/ABI changes.
1 parent ad3e39d commit b927efc

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Include/internal/pycore_pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
8484
PyAPI_FUNC(int) _PyInterpreterState_SetRunningMain(PyInterpreterState *);
8585
PyAPI_FUNC(void) _PyInterpreterState_SetNotRunningMain(PyInterpreterState *);
8686
PyAPI_FUNC(int) _PyInterpreterState_IsRunningMain(PyInterpreterState *);
87-
PyAPI_FUNC(void) _PyErr_SetInterpreterAlreadyRunning(void);
87+
PyAPI_FUNC(int) _PyInterpreterState_FailIfRunningMain(PyInterpreterState *);
8888

8989
extern int _PyThreadState_IsRunningMain(PyThreadState *);
9090
extern void _PyInterpreterState_ReinitRunningMain(PyThreadState *);

Python/crossinterp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,8 @@ _PyXI_ApplyErrorCode(_PyXI_errcode code, PyInterpreterState *interp)
985985
break;
986986
case _PyXI_ERR_ALREADY_RUNNING:
987987
assert(interp != NULL);
988-
_PyErr_SetInterpreterAlreadyRunning();
988+
// In 3.14+ we use _PyErr_SetInterpreterAlreadyRunning().
989+
PyErr_SetString(PyExc_InterpreterError, "interpreter already running");
989990
break;
990991
case _PyXI_ERR_MAIN_NS_FAILURE:
991992
PyErr_SetString(PyExc_InterpreterError,

Python/pystate.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,17 +1050,12 @@ get_main_thread(PyInterpreterState *interp)
10501050
return _Py_atomic_load_ptr_relaxed(&interp->threads.main);
10511051
}
10521052

1053-
void
1054-
_PyErr_SetInterpreterAlreadyRunning(void)
1055-
{
1056-
PyErr_SetString(PyExc_InterpreterError, "interpreter already running");
1057-
}
1058-
10591053
int
10601054
_PyInterpreterState_SetRunningMain(PyInterpreterState *interp)
10611055
{
10621056
if (get_main_thread(interp) != NULL) {
1063-
_PyErr_SetInterpreterAlreadyRunning();
1057+
// In 3.14+ we use _PyErr_SetInterpreterAlreadyRunning().
1058+
PyErr_SetString(PyExc_InterpreterError, "interpreter already running");
10641059
return -1;
10651060
}
10661061
PyThreadState *tstate = current_fast_get();
@@ -1106,6 +1101,18 @@ _PyThreadState_IsRunningMain(PyThreadState *tstate)
11061101
return get_main_thread(interp) == tstate;
11071102
}
11081103

1104+
// This has been removed in 3.14.
1105+
int
1106+
_PyInterpreterState_FailIfRunningMain(PyInterpreterState *interp)
1107+
{
1108+
if (get_main_thread(interp) != NULL) {
1109+
PyErr_SetString(PyExc_InterpreterError,
1110+
"interpreter already running");
1111+
return -1;
1112+
}
1113+
return 0;
1114+
}
1115+
11091116
void
11101117
_PyInterpreterState_ReinitRunningMain(PyThreadState *tstate)
11111118
{

0 commit comments

Comments
 (0)