From 924c5fc08fd0b7306af43bebfc304371816d11de Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Tue, 28 Jul 2026 12:06:52 -0400 Subject: [PATCH] gh-154822: Fix racy assertion during finalization (GH-154824) (cherry picked from commit cb0f028537448db9457747873f8f4c9e6b607500) Co-authored-by: Peter Bierma --- Python/pylifecycle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 3933c321ed2e3df..516d467141ade75 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -3820,8 +3820,8 @@ handle_thread_shutdown_exception(PyThreadState *tstate) assert(tstate != NULL); assert(_PyErr_Occurred(tstate)); PyInterpreterState *interp = tstate->interp; - assert(interp->threads.head != NULL); _PyEval_StopTheWorld(interp); + assert(interp->threads.head != NULL); // We don't have to worry about locking this because the // world is stopped.