From 43ee75dd4e97863a05c8dec286f3ef491aa05a9d Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Tue, 23 Aug 2022 00:10:23 +0530 Subject: [PATCH] [3.10] GH-96071: add regression test for GH-96071 (GH-96137) Automerge-Triggered-By: GH:ericsnowcurrently (cherry picked from commit 079baee1962ff7c1f4b60f4dd4c803535ecbd18e) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- Lib/test/test_capi.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 7b208c90063fd5..0adb689beb8208 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -825,6 +825,20 @@ def callback(): 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))