Skip to content

Commit 31f149d

Browse files
authored
gh-128679: Use _PyThreadState_GET() in tracemalloc.c (#129126)
Replace uncommon PyGILState_GetThisThreadState() with common _PyThreadState_GET().
1 parent 6a0f915 commit 31f149d

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Python/tracemalloc.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,8 @@ traceback_hash(traceback_t *traceback)
338338
static void
339339
traceback_get_frames(traceback_t *traceback)
340340
{
341-
PyThreadState *tstate = PyGILState_GetThisThreadState();
342-
if (tstate == NULL) {
343-
#ifdef TRACE_DEBUG
344-
tracemalloc_error("failed to get the current thread state");
345-
#endif
346-
return;
347-
}
341+
PyThreadState *tstate = _PyThreadState_GET();
342+
assert(tstate != NULL);
348343

349344
_PyInterpreterFrame *pyframe = _PyThreadState_GetFrame(tstate);
350345
while (pyframe) {

0 commit comments

Comments
 (0)