https://github.com/python/cpython/commit/31f149d5b3a5c6cb1160a052c96a35c36f2a27db
commit: 31f149d5b3a5c6cb1160a052c96a35c36f2a27db
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-01-21T14:43:31+01:00
summary:

gh-128679: Use _PyThreadState_GET() in tracemalloc.c (#129126)

Replace uncommon PyGILState_GetThisThreadState() with common
_PyThreadState_GET().

files:
M Python/tracemalloc.c

diff --git a/Python/tracemalloc.c b/Python/tracemalloc.c
index a9f45e5ead1a11..b398ea379e0607 100644
--- a/Python/tracemalloc.c
+++ b/Python/tracemalloc.c
@@ -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) {

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to