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

Automerge-Triggered-By: GH:ericsnowcurrently
(cherry picked from commit 079baee196)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-08-23 08:37:19 -07:00 committed by GitHub
parent 27950d8f76
commit 0aed1e71f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -915,6 +915,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))