From: Peter Bierma Date: Tue, 23 Sep 2025 14:09:19 +0000 (-0400) Subject: gh-126016: Fix flaky test by allowing the SIGINT return code (GH-139219) X-Git-Tag: v3.15.0a1~225 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b4e3fe9d42708ca6e8cfb7407c22647787a6b29;p=thirdparty%2FPython%2Fcpython.git gh-126016: Fix flaky test by allowing the SIGINT return code (GH-139219) --- diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index 8e9f1c3204a8..9a5ee03e4722 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -459,7 +459,12 @@ class InterpreterObjectTests(TestBase): 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):