File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1914,6 +1914,33 @@ def test_keyerror_context(self):
19141914 exc2 = None
19151915
19161916
1917+ @cpython_only
1918+ # Python built with Py_TRACE_REFS fail with a fatal error in
1919+ # _PyRefchain_Trace() on memory allocation error.
1920+ @unittest .skipIf (support .Py_TRACE_REFS , 'cannot test Py_TRACE_REFS build' )
1921+ def test_exec_set_nomemory_hang (self ):
1922+ import_module ("_testcapi" )
1923+ # gh-134163: chore from branch 3.13
1924+ warmup_code = "a = list(range(0, 1))\n " * 20
1925+ user_input = warmup_code + dedent ("""
1926+ try:
1927+ import _testcapi
1928+ _testcapi.set_nomemory(0)
1929+ b = list(range(1000, 2000))
1930+ except Exception as e:
1931+ import traceback
1932+ traceback.print_exc()
1933+ """ )
1934+ with SuppressCrashReport ():
1935+ with script_helper .spawn_python ('-c' , user_input ) as p :
1936+ p .wait ()
1937+ output = p .stdout .read ()
1938+
1939+ self .assertIn (p .returncode , (0 , 1 ))
1940+ self .assertGreater (len (output ), 0 ) # At minimum, should not hang
1941+ self .assertIn (b"MemoryError" , output )
1942+
1943+
19171944class NameErrorTests (unittest .TestCase ):
19181945 def test_name_error_has_name (self ):
19191946 try :
You can’t perform that action at this time.
0 commit comments