Skip to content

Commit 2152dc3

Browse files
committed
Avoid more direct PyThreadState accesses
1 parent 08bf50d commit 2152dc3

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/c/call_python.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
static PyObject *_current_interp_key(void)
22
{
3-
PyInterpreterState *interp = PyThreadState_GET()->interp;
3+
PyInterpreterState *interp = PyInterpreterState_Get();
44
return PyInterpreterState_GetDict(interp); /* shared reference */
55
}
66

@@ -17,13 +17,17 @@ static PyObject *_get_interpstate_dict(void)
1717
int err;
1818
PyInterpreterState *interp;
1919

20-
tstate = PyThreadState_GET();
20+
#if PY_VERSION_HEX >= 0x030D0000
21+
tstate = PyThreadState_GetUnchecked();
22+
#else
23+
tstate = _PyThreadState_UncheckedGet();
24+
#endif
2125
if (tstate == NULL) {
2226
/* no thread state! */
2327
return NULL;
2428
}
2529

26-
interp = tstate->interp;
30+
interp = PyThreadState_GetInterpreter(tstate);
2731
interpdict = PyInterpreterState_GetDict(interp); /* shared reference */
2832
if (interpdict == NULL) {
2933
/* subinterpreter was cleared already, or is being cleared right now,

0 commit comments

Comments
 (0)