]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-32436: Use PyThreadState_GET() in all hot paths (GH-5363)
authorYury Selivanov <yury@magic.io>
Sat, 27 Jan 2018 18:24:20 +0000 (13:24 -0500)
committerGitHub <noreply@github.com>
Sat, 27 Jan 2018 18:24:20 +0000 (13:24 -0500)
Python/context.c

index 3928e94d06453826d45a68742fe5eaff10017c27..2034a204121501f73425c8a95520eb6a753e7f27 100644 (file)
@@ -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();