aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-01-27 13:24:20 -0500
committerGitHub <noreply@github.com>2018-01-27 13:24:20 -0500
commitbc4123b0b380edda774b8bff2fa1bcc96453b440 (patch)
treec275ebfbdea29680eee67b4d21ef2f36c91066a7 /Python/context.c
parentFix wrong assert in unicodeobject (GH-5340) (diff)
downloadcpython-bc4123b0b380edda774b8bff2fa1bcc96453b440.tar.gz
cpython-bc4123b0b380edda774b8bff2fa1bcc96453b440.tar.bz2
cpython-bc4123b0b380edda774b8bff2fa1bcc96453b440.zip
bpo-32436: Use PyThreadState_GET() in all hot paths (GH-5363)
Diffstat (limited to 'Python/context.c')
-rw-r--r--Python/context.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/context.c b/Python/context.c
index 3928e94d064..2034a204121 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -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;
@@ -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 */
@@ -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();