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

Replace uncommon PyGILState_GetThisThreadState() with common
_PyThreadState_GET().
This commit is contained in:
Victor Stinner 2025-01-21 14:43:31 +01:00 committed by GitHub
parent 6a0f915aae
commit 31f149d5b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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