]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] GH-96071: add regression test for GH-96071 (GH-96137) (#96205)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Tue, 23 Aug 2022 22:28:54 +0000 (03:58 +0530)
committerGitHub <noreply@github.com>
Tue, 23 Aug 2022 22:28:54 +0000 (23:28 +0100)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Lib/test/test_capi.py

index 7b208c90063fd5d9d52d995dad46f11a806289ae..0adb689beb820841589ab8ff481d365d2bba41b6 100644 (file)
@@ -825,6 +825,20 @@ class TestThreadState(unittest.TestCase):
         t.start()
         t.join()
 
+    @threading_helper.reap_threads
+    def test_gilstate_ensure_no_deadlock(self):
+        # See https://github.com/python/cpython/issues/96071
+        code = textwrap.dedent(f"""
+            import _testcapi
+
+            def callback():
+                print('callback called')
+
+            _testcapi._test_thread_state(callback)
+            """)
+        ret = assert_python_ok('-X', 'tracemalloc', '-c', code)
+        self.assertIn(b'callback called', ret.out)
+
 
 class Test_testcapi(unittest.TestCase):
     locals().update((name, getattr(_testcapi, name))