https://github.com/python/cpython/commit/6b4e3fe9d42708ca6e8cfb7407c22647787a6b29
commit: 6b4e3fe9d42708ca6e8cfb7407c22647787a6b29
branch: main
author: Peter Bierma <[email protected]>
committer: encukou <[email protected]>
date: 2025-09-23T16:09:19+02:00
summary:

gh-126016: Fix flaky test by allowing the SIGINT return code (GH-139219)

files:
M Lib/test/test_interpreters/test_api.py

diff --git a/Lib/test/test_interpreters/test_api.py 
b/Lib/test/test_interpreters/test_api.py
index 8e9f1c3204a8bb..9a5ee03e4722c0 100644
--- a/Lib/test/test_interpreters/test_api.py
+++ b/Lib/test/test_interpreters/test_api.py
@@ -459,7 +459,12 @@ def test():
             error = proc.stderr.read()
             self.assertIn(b"KeyboardInterrupt", error)
             retcode = proc.wait()
-            self.assertEqual(retcode, 0)
+            # Sometimes we send the SIGINT after the subthread yields the GIL 
to
+            # the main thread, which results in the main thread getting the
+            # KeyboardInterrupt before finalization is reached. There's not
+            # any great way to protect against that, so we just allow a -2
+            # return code as well.
+            self.assertIn(retcode, (0, -signal.SIGINT))
 
 
 class TestInterpreterIsRunning(TestBase):

_______________________________________________
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