]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128679: Use _PyThreadState_GET() in tracemalloc.c (#129126)
authorVictor Stinner <vstinner@python.org>
Tue, 21 Jan 2025 13:43:31 +0000 (14:43 +0100)
committerGitHub <noreply@github.com>
Tue, 21 Jan 2025 13:43:31 +0000 (14:43 +0100)
Replace uncommon PyGILState_GetThisThreadState() with common
_PyThreadState_GET().

Python/tracemalloc.c

index a9f45e5ead1a11d58b0dca6b0de613bfab33e7df..b398ea379e0607c567c77061180e5c5be3696726 100644 (file)
@@ -338,13 +338,8 @@ traceback_hash(traceback_t *traceback)
 static void
 traceback_get_frames(traceback_t *traceback)
 {
-    PyThreadState *tstate = PyGILState_GetThisThreadState();
-    if (tstate == NULL) {
-#ifdef TRACE_DEBUG
-        tracemalloc_error("failed to get the current thread state");
-#endif
-        return;
-    }
+    PyThreadState *tstate = _PyThreadState_GET();
+    assert(tstate != NULL);
 
     _PyInterpreterFrame *pyframe = _PyThreadState_GetFrame(tstate);
     while (pyframe) {