[Python-checkins] GH-96071: add regression test for #96071 (GH-96137)

miss-islington webhook-mailer at python.org
Mon Aug 22 14:40:38 EDT 2022


https://github.com/python/cpython/commit/079baee1962ff7c1f4b60f4dd4c803535ecbd18e
commit: 079baee1962ff7c1f4b60f4dd4c803535ecbd18e
branch: main
author: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-08-22T11:40:23-07:00
summary:

GH-96071: add regression test for #96071 (GH-96137)



Automerge-Triggered-By: GH:ericsnowcurrently

files:
M Lib/test/test_capi.py

diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index b698e34dec4..d0c4811cad1 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -1053,6 +1053,21 @@ def callback():
         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))



More information about the Python-checkins mailing list