mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-32436: Use PyThreadState_GET() in all hot paths (GH-5363)
This commit is contained in:
parent
7cc95f5069
commit
bc4123b0b3
1 changed files with 6 additions and 3 deletions
|
@ -85,7 +85,8 @@ PyContext_Enter(PyContext *ctx)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyThreadState *ts = PyThreadState_Get();
|
PyThreadState *ts = PyThreadState_GET();
|
||||||
|
assert(ts != NULL);
|
||||||
|
|
||||||
ctx->ctx_prev = (PyContext *)ts->context; /* borrow */
|
ctx->ctx_prev = (PyContext *)ts->context; /* borrow */
|
||||||
ctx->ctx_entered = 1;
|
ctx->ctx_entered = 1;
|
||||||
|
@ -107,7 +108,8 @@ PyContext_Exit(PyContext *ctx)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyThreadState *ts = PyThreadState_Get();
|
PyThreadState *ts = PyThreadState_GET();
|
||||||
|
assert(ts != NULL);
|
||||||
|
|
||||||
if (ts->context != (PyObject *)ctx) {
|
if (ts->context != (PyObject *)ctx) {
|
||||||
/* Can only happen if someone misuses the C API */
|
/* Can only happen if someone misuses the C API */
|
||||||
|
@ -341,7 +343,8 @@ context_new_from_vars(PyHamtObject *vars)
|
||||||
static inline PyContext *
|
static inline PyContext *
|
||||||
context_get(void)
|
context_get(void)
|
||||||
{
|
{
|
||||||
PyThreadState *ts = PyThreadState_Get();
|
PyThreadState *ts = PyThreadState_GET();
|
||||||
|
assert(ts != NULL);
|
||||||
PyContext *current_ctx = (PyContext *)ts->context;
|
PyContext *current_ctx = (PyContext *)ts->context;
|
||||||
if (current_ctx == NULL) {
|
if (current_ctx == NULL) {
|
||||||
current_ctx = context_new_empty();
|
current_ctx = context_new_empty();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue