@@ -99,7 +99,11 @@ def test_no_memory(self):
9999 self .assertIn (p .returncode , (1 , 120 ))
100100
101101 @cpython_only
102+ # Python built with Py_TRACE_REFS fail with a fatal error in
103+ # _PyRefchain_Trace() on memory allocation error.
104+ @unittest .skipIf (support .Py_TRACE_REFS , 'cannot test Py_TRACE_REFS build' )
102105 def test_exec_set_nomemory_hang (self ):
106+ import_module ("_testcapi" )
103107 # gh-134163: Test case that triggers no memory hang condition
104108 # The frame_lasti need to upper 257,
105109 # because when calling PyLong_FromLong, malloc is not invoked,
@@ -120,12 +124,10 @@ def test_exec_set_nomemory_hang(self):
120124 p .stdin .write (user_input )
121125 output = kill_python (p )
122126
123- # it can exit with MemoryError or Fatal Python error when --with-trace-refs
124- # it return -6 here
125- self .assertIn (p .returncode , (0 , 1 , 120 , - 6 ))
127+ self .assertIn (p .returncode , (0 , 1 , 120 ))
126128 self .assertGreater (len (output ), 0 ) # At minimum, should not hang
127129 # Can result in either MemoryError exception or fatal error
128- self .assertTrue ("MemoryError" in output or "Fatal Python error" in output )
130+ self .assertTrue ("MemoryError" in output )
129131
130132 @cpython_only
131133 def test_multiline_string_parsing (self ):
0 commit comments