Skip to content

Commit bc4123b

Browse files
authored
bpo-32436: Use PyThreadState_GET() in all hot paths (GH-5363)
1 parent 7cc95f5 commit bc4123b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/context.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ PyContext_Enter(PyContext *ctx)
8585
return -1;
8686
}
8787

88-
PyThreadState *ts = PyThreadState_Get();
88+
PyThreadState *ts = PyThreadState_GET();
89+
assert(ts != NULL);
8990

9091
ctx->ctx_prev = (PyContext *)ts->context; /* borrow */
9192
ctx->ctx_entered = 1;
@@ -107,7 +108,8 @@ PyContext_Exit(PyContext *ctx)
107108
return -1;
108109
}
109110

110-
PyThreadState *ts = PyThreadState_Get();
111+
PyThreadState *ts = PyThreadState_GET();
112+
assert(ts != NULL);
111113

112114
if (ts->context != (PyObject *)ctx) {
113115
/* Can only happen if someone misuses the C API */
@@ -341,7 +343,8 @@ context_new_from_vars(PyHamtObject *vars)
341343
static inline PyContext *
342344
context_get(void)
343345
{
344-
PyThreadState *ts = PyThreadState_Get();
346+
PyThreadState *ts = PyThreadState_GET();
347+
assert(ts != NULL);
345348
PyContext *current_ctx = (PyContext *)ts->context;
346349
if (current_ctx == NULL) {
347350
current_ctx = context_new_empty();

0 commit comments

Comments
 (0)