]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-96071: add regression test for #96071 (GH-96137)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Mon, 22 Aug 2022 18:40:23 +0000 (00:10 +0530)
committerGitHub <noreply@github.com>
Mon, 22 Aug 2022 18:40:23 +0000 (11:40 -0700)
Automerge-Triggered-By: GH:ericsnowcurrently
Lib/test/test_capi.py

index b698e34dec4e22380143e4dd3e5cc717255b49ce..d0c4811cad1993f58e4c11e06476bb5fbd2f0184 100644 (file)
@@ -1053,6 +1053,21 @@ class TestThreadState(unittest.TestCase):
         t.start()
         t.join()
 
+    @threading_helper.reap_threads
+    @threading_helper.requires_working_threading()
+    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))