mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
gh-126986: Drop _PyInterpreterState_FailIfNotRunning() (gh-126988)
We replace it with _PyErr_SetInterpreterAlreadyRunning().
This commit is contained in:
parent
0063f5f314
commit
d6b3e78504
3 changed files with 10 additions and 15 deletions
|
@ -82,7 +82,7 @@ PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
|
||||||
PyAPI_FUNC(int) _PyInterpreterState_SetRunningMain(PyInterpreterState *);
|
PyAPI_FUNC(int) _PyInterpreterState_SetRunningMain(PyInterpreterState *);
|
||||||
PyAPI_FUNC(void) _PyInterpreterState_SetNotRunningMain(PyInterpreterState *);
|
PyAPI_FUNC(void) _PyInterpreterState_SetNotRunningMain(PyInterpreterState *);
|
||||||
PyAPI_FUNC(int) _PyInterpreterState_IsRunningMain(PyInterpreterState *);
|
PyAPI_FUNC(int) _PyInterpreterState_IsRunningMain(PyInterpreterState *);
|
||||||
PyAPI_FUNC(int) _PyInterpreterState_FailIfRunningMain(PyInterpreterState *);
|
PyAPI_FUNC(void) _PyErr_SetInterpreterAlreadyRunning(void);
|
||||||
|
|
||||||
extern int _PyThreadState_IsRunningMain(PyThreadState *);
|
extern int _PyThreadState_IsRunningMain(PyThreadState *);
|
||||||
extern void _PyInterpreterState_ReinitRunningMain(PyThreadState *);
|
extern void _PyInterpreterState_ReinitRunningMain(PyThreadState *);
|
||||||
|
|
|
@ -983,8 +983,7 @@ _PyXI_ApplyErrorCode(_PyXI_errcode code, PyInterpreterState *interp)
|
||||||
break;
|
break;
|
||||||
case _PyXI_ERR_ALREADY_RUNNING:
|
case _PyXI_ERR_ALREADY_RUNNING:
|
||||||
assert(interp != NULL);
|
assert(interp != NULL);
|
||||||
assert(_PyInterpreterState_IsRunningMain(interp));
|
_PyErr_SetInterpreterAlreadyRunning();
|
||||||
_PyInterpreterState_FailIfRunningMain(interp);
|
|
||||||
break;
|
break;
|
||||||
case _PyXI_ERR_MAIN_NS_FAILURE:
|
case _PyXI_ERR_MAIN_NS_FAILURE:
|
||||||
PyErr_SetString(PyExc_InterpreterError,
|
PyErr_SetString(PyExc_InterpreterError,
|
||||||
|
|
|
@ -1047,10 +1047,17 @@ get_main_thread(PyInterpreterState *interp)
|
||||||
return _Py_atomic_load_ptr_relaxed(&interp->threads.main);
|
return _Py_atomic_load_ptr_relaxed(&interp->threads.main);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_PyErr_SetInterpreterAlreadyRunning(void)
|
||||||
|
{
|
||||||
|
PyErr_SetString(PyExc_InterpreterError, "interpreter already running");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_PyInterpreterState_SetRunningMain(PyInterpreterState *interp)
|
_PyInterpreterState_SetRunningMain(PyInterpreterState *interp)
|
||||||
{
|
{
|
||||||
if (_PyInterpreterState_FailIfRunningMain(interp) < 0) {
|
if (get_main_thread(interp) != NULL) {
|
||||||
|
_PyErr_SetInterpreterAlreadyRunning();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PyThreadState *tstate = current_fast_get();
|
PyThreadState *tstate = current_fast_get();
|
||||||
|
@ -1096,17 +1103,6 @@ _PyThreadState_IsRunningMain(PyThreadState *tstate)
|
||||||
return get_main_thread(interp) == 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
|
void
|
||||||
_PyInterpreterState_ReinitRunningMain(PyThreadState *tstate)
|
_PyInterpreterState_ReinitRunningMain(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue