From 96146ddfed498303f4b9aa3e73cda16167d64b98 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 21 Jan 2025 11:18:59 +0100 Subject: [PATCH] gh-128679: Use _PyThreadState_GET() in tracemalloc.c Replace uncommon PyGILState_GetThisThreadState() with common _PyThreadState_GET(). --- Python/tracemalloc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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) {