@@ -102,20 +102,11 @@ def test_no_memory(self):
102102 def test_exec_set_nomemory_hang (self ):
103103 # gh-134163: Test case that triggers no memory hang condition
104104 user_input = dedent ("""
105- a1 = list(range(1000, 2000))
106- a2 = list(range(1000, 2000))
107- a3 = list(range(1000, 2000))
108- a4 = list(range(1000, 2000))
109- a5 = list(range(1000, 2000))
110- a6 = list(range(1000, 2000))
111- a7 = list(range(1000, 2000))
112- a8 = list(range(1000, 2000))
113- a9 = list(range(1000, 2000))
114- a10 = list(range(1000, 2000))
115- a11 = list(range(1000, 2000))
116- a12 = list(range(1000, 2000))
117- a13 = list(range(1000, 2000))
118- a14 = list(range(1000, 2000))
105+ # The frame_lasti need to upper 257,
106+ # because when calling PyLong_FromLong, malloc is not invoked,
107+ # so no MemError is triggered
108+ # we need to warm up the memory to reproduce the issue
109+ "a = list(range(0, 1))\n " * 20
119110 try:
120111 import _testcapi
121112 _testcapi.set_nomemory(0)
@@ -130,12 +121,7 @@ def test_exec_set_nomemory_hang(self):
130121 output = kill_python (p )
131122
132123 self .assertIn (p .returncode , (0 , 1 , 120 ))
133- # The key test is that it doesn't hang - if we get output, the test passed
134- # Look for either successful execution or memory error indicators
135- has_traceback = "Traceback" in output
136- has_memory_error = "MemoryError" in output
137- # Either we get a traceback (expected) or we complete without hanging
138- self .assertTrue (len (output ) > 0 , f"Expected some output, got: { output } " ) # At minimum, should not hang
124+ self .assertGreater (len (output ), 0 , f"Expected some output, got: { output } " ) # At minimum, should not hang
139125
140126 @cpython_only
141127 def test_multiline_string_parsing (self ):
0 commit comments