https://github.com/python/cpython/commit/de106cc32146e61d07dea2c65d78b4e73c5035d2
commit: de106cc32146e61d07dea2c65d78b4e73c5035d2
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2026-07-28T16:39:33Z
summary:

[3.15] gh-154822: Fix racy assertion during finalization (GH-154824) (GH-154828)

(cherry picked from commit cb0f028537448db9457747873f8f4c9e6b607500)

Co-authored-by: Peter Bierma <[email protected]>

files:
M Python/pylifecycle.c

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 3933c321ed2e3d..516d467141ade7 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.

_______________________________________________
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