Skip to content

Commit 1257ecf

Browse files
committed
pythongh-103323: Remove PyRuntimeState_GetThreadState()
This function no longer makes sense, since its runtime parameter is no longer used. Use directly _PyThreadState_GET() and _PyInterpreterState_GET() instead.
1 parent e2ef501 commit 1257ecf

File tree

5 files changed

+7
-15
lines changed

5 files changed

+7
-15
lines changed

Include/internal/pycore_pystate.h

-6
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ _PyThreadState_GET(void)
9393
#endif
9494
}
9595

96-
static inline PyThreadState*
97-
_PyRuntimeState_GetThreadState(_PyRuntimeState *Py_UNUSED(runtime))
98-
{
99-
return _PyThreadState_GET();
100-
}
101-
10296

10397
static inline void
10498
_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)

Python/ceval_gil.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,7 @@ _PyEval_Fini(void)
546546
void
547547
PyEval_AcquireLock(void)
548548
{
549-
_PyRuntimeState *runtime = &_PyRuntime;
550-
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
549+
PyThreadState *tstate = _PyThreadState_GET();
551550
_Py_EnsureTstateNotNULL(tstate);
552551

553552
take_gil(tstate);
@@ -557,7 +556,7 @@ void
557556
PyEval_ReleaseLock(void)
558557
{
559558
_PyRuntimeState *runtime = &_PyRuntime;
560-
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
559+
PyThreadState *tstate = _PyThreadState_GET();
561560
/* This function must succeed when the current thread state is NULL.
562561
We therefore avoid PyThreadState_Get() which dumps a fatal error
563562
in debug mode. */

Python/pylifecycle.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -1303,8 +1303,7 @@ _Py_InitializeMain(void)
13031303
if (_PyStatus_EXCEPTION(status)) {
13041304
return status;
13051305
}
1306-
_PyRuntimeState *runtime = &_PyRuntime;
1307-
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
1306+
PyThreadState *tstate = _PyThreadState_GET();
13081307
return pyinit_main(tstate);
13091308
}
13101309

@@ -1755,7 +1754,7 @@ Py_FinalizeEx(void)
17551754
}
17561755

17571756
/* Get current thread state and interpreter pointer */
1758-
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
1757+
PyThreadState *tstate = _PyThreadState_GET();
17591758
// XXX assert(_Py_IsMainInterpreter(tstate->interp));
17601759
// XXX assert(_Py_IsMainThread());
17611760

@@ -2800,7 +2799,7 @@ fatal_error(int fd, int header, const char *prefix, const char *msg,
28002799
28012800
tss_tstate != tstate if the current Python thread does not hold the GIL.
28022801
*/
2803-
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
2802+
PyThreadState *tstate = _PyThreadState_GET();
28042803
PyInterpreterState *interp = NULL;
28052804
PyThreadState *tss_tstate = PyGILState_GetThisThreadState();
28062805
if (tstate != NULL) {

Python/pystate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ int
18091809
PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
18101810
{
18111811
_PyRuntimeState *runtime = &_PyRuntime;
1812-
PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
1812+
PyInterpreterState *interp = _PyInterpreterState_GET();
18131813

18141814
/* Although the GIL is held, a few C API functions can be called
18151815
* without the GIL held, and in particular some that create and

Python/sysmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
365365
_PyRuntimeState *runtime = &_PyRuntime;
366366
PyThreadState *tstate;
367367
if (runtime->initialized) {
368-
tstate = _PyRuntimeState_GetThreadState(runtime);
368+
tstate = _PyThreadState_GET();
369369
}
370370
else {
371371
tstate = NULL;

0 commit comments

Comments
 (0)