mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
gh-103323: Remove PyRuntimeState_GetThreadState() (#104171)
This function no longer makes sense, since its runtime parameter is no longer used. Use directly _PyThreadState_GET() and _PyInterpreterState_GET() instead.
This commit is contained in:
parent
eba64d2afb
commit
45398ad512
5 changed files with 9 additions and 17 deletions
|
|
@ -68,7 +68,7 @@ _Py_ThreadCanHandlePendingCalls(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Variable and macro for in-line access to current thread
|
/* Variable and static inline functions for in-line access to current thread
|
||||||
and interpreter state */
|
and interpreter state */
|
||||||
|
|
||||||
#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)
|
#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)
|
||||||
|
|
@ -93,12 +93,6 @@ _PyThreadState_GET(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline PyThreadState*
|
|
||||||
_PyRuntimeState_GetThreadState(_PyRuntimeState *Py_UNUSED(runtime))
|
|
||||||
{
|
|
||||||
return _PyThreadState_GET();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
|
_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
|
||||||
|
|
@ -118,7 +112,7 @@ _Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
|
||||||
|
|
||||||
/* Get the current interpreter state.
|
/* Get the current interpreter state.
|
||||||
|
|
||||||
The macro is unsafe: it does not check for error and it can return NULL.
|
The function is unsafe: it does not check for error and it can return NULL.
|
||||||
|
|
||||||
The caller must hold the GIL.
|
The caller must hold the GIL.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -546,8 +546,7 @@ _PyEval_Fini(void)
|
||||||
void
|
void
|
||||||
PyEval_AcquireLock(void)
|
PyEval_AcquireLock(void)
|
||||||
{
|
{
|
||||||
_PyRuntimeState *runtime = &_PyRuntime;
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
|
||||||
_Py_EnsureTstateNotNULL(tstate);
|
_Py_EnsureTstateNotNULL(tstate);
|
||||||
|
|
||||||
take_gil(tstate);
|
take_gil(tstate);
|
||||||
|
|
@ -557,7 +556,7 @@ void
|
||||||
PyEval_ReleaseLock(void)
|
PyEval_ReleaseLock(void)
|
||||||
{
|
{
|
||||||
_PyRuntimeState *runtime = &_PyRuntime;
|
_PyRuntimeState *runtime = &_PyRuntime;
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
/* This function must succeed when the current thread state is NULL.
|
/* This function must succeed when the current thread state is NULL.
|
||||||
We therefore avoid PyThreadState_Get() which dumps a fatal error
|
We therefore avoid PyThreadState_Get() which dumps a fatal error
|
||||||
in debug mode. */
|
in debug mode. */
|
||||||
|
|
|
||||||
|
|
@ -1303,8 +1303,7 @@ _Py_InitializeMain(void)
|
||||||
if (_PyStatus_EXCEPTION(status)) {
|
if (_PyStatus_EXCEPTION(status)) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
_PyRuntimeState *runtime = &_PyRuntime;
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
|
||||||
return pyinit_main(tstate);
|
return pyinit_main(tstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1755,7 +1754,7 @@ Py_FinalizeEx(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get current thread state and interpreter pointer */
|
/* Get current thread state and interpreter pointer */
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
// XXX assert(_Py_IsMainInterpreter(tstate->interp));
|
// XXX assert(_Py_IsMainInterpreter(tstate->interp));
|
||||||
// XXX assert(_Py_IsMainThread());
|
// XXX assert(_Py_IsMainThread());
|
||||||
|
|
||||||
|
|
@ -2800,7 +2799,7 @@ fatal_error(int fd, int header, const char *prefix, const char *msg,
|
||||||
|
|
||||||
tss_tstate != tstate if the current Python thread does not hold the GIL.
|
tss_tstate != tstate if the current Python thread does not hold the GIL.
|
||||||
*/
|
*/
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyInterpreterState *interp = NULL;
|
PyInterpreterState *interp = NULL;
|
||||||
PyThreadState *tss_tstate = PyGILState_GetThisThreadState();
|
PyThreadState *tss_tstate = PyGILState_GetThisThreadState();
|
||||||
if (tstate != NULL) {
|
if (tstate != NULL) {
|
||||||
|
|
|
||||||
|
|
@ -1809,7 +1809,7 @@ int
|
||||||
PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
|
PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
|
||||||
{
|
{
|
||||||
_PyRuntimeState *runtime = &_PyRuntime;
|
_PyRuntimeState *runtime = &_PyRuntime;
|
||||||
PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
|
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||||
|
|
||||||
/* Although the GIL is held, a few C API functions can be called
|
/* Although the GIL is held, a few C API functions can be called
|
||||||
* without the GIL held, and in particular some that create and
|
* without the GIL held, and in particular some that create and
|
||||||
|
|
|
||||||
|
|
@ -365,7 +365,7 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
|
||||||
_PyRuntimeState *runtime = &_PyRuntime;
|
_PyRuntimeState *runtime = &_PyRuntime;
|
||||||
PyThreadState *tstate;
|
PyThreadState *tstate;
|
||||||
if (runtime->initialized) {
|
if (runtime->initialized) {
|
||||||
tstate = _PyRuntimeState_GetThreadState(runtime);
|
tstate = _PyThreadState_GET();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tstate = NULL;
|
tstate = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue