Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45398ad

Browse filesBrowse files
authored
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.
1 parent eba64d2 commit 45398ad
Copy full SHA for 45398ad

File tree

5 files changed

+9
-17
lines changed
Filter options

5 files changed

+9
-17
lines changed

‎Include/internal/pycore_pystate.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_pystate.h
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _Py_ThreadCanHandlePendingCalls(void)
6868
}
6969

7070

71-
/* Variable and macro for in-line access to current thread
71+
/* Variable and static inline functions for in-line access to current thread
7272
and interpreter state */
7373

7474
#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)
@@ -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)
@@ -118,7 +112,7 @@ _Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
118112

119113
/* Get the current interpreter state.
120114
121-
The macro is unsafe: it does not check for error and it can return NULL.
115+
The function is unsafe: it does not check for error and it can return NULL.
122116
123117
The caller must hold the GIL.
124118

‎Python/ceval_gil.c

Copy file name to clipboardExpand all lines: Python/ceval_gil.c
+2-3Lines changed: 2 additions & 3 deletions
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

Copy file name to clipboardExpand all lines: Python/pylifecycle.c
+3-4Lines changed: 3 additions & 4 deletions
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

Copy file name to clipboardExpand all lines: Python/pystate.c
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: Python/sysmodule.c
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.