E5EA bpo-32436: Use PyThreadState_GET() in all hot paths by 1st1 · Pull Request #5363 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Python/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ PyContext_Enter(PyContext *ctx)
return -1;
}

PyThreadState *ts = PyThreadState_Get();
PyThreadState *ts = PyThreadState_GET();
assert(ts != NULL);

ctx->ctx_prev = (PyContext *)ts->context; /* borrow */
ctx->ctx_entered = 1;
Expand All @@ -107,7 +108,8 @@ PyContext_Exit(PyContext *ctx)
return -1;
}

PyThreadState *ts = PyThreadState_Get();
PyThreadState *ts = PyThreadState_GET();
assert(ts != NULL);

if (ts->context != (PyObject *)ctx) {
/* Can only happen if someone misuses the C API */
Expand Down Expand Up @@ -341,7 +343,8 @@ context_new_from_vars(PyHamtObject *vars)
static inline PyContext *
context_get(void)
{
PyThreadState *ts = PyThreadState_Get();
PyThreadState *ts = PyThreadState_GET();
assert(ts != NULL);
PyContext *current_ctx = (PyContext *)ts->context;
if (current_ctx == NULL) {
current_ctx = context_new_empty();
Expand Down
0