@@ -101,12 +101,12 @@ def test_no_memory(self):
101101    @cpython_only  
102102    def  test_exec_set_nomemory_hang (self ):
103103        # gh-134163: Test case that triggers no memory hang condition 
104-         user_input   =   dedent ( """ 
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  
104+         # The frame_lasti need to upper 257, 
105+         # because when calling PyLong_FromLong, malloc is not invoked ,
106+         # so no MemError  is triggered 
107+         # we need to warm up the memory to reproduce the issue 
108+         warmup_code   =   "a = list(range(0, 1)) \n "   *   20 
109+         user_input   =   warmup_code   +   dedent ( """ 
110110            try: 
111111                import _testcapi 
112112                _testcapi.set_nomemory(0) 
@@ -122,6 +122,7 @@ def test_exec_set_nomemory_hang(self):
122122
123123        self .assertIn (p .returncode , (0 , 1 , 120 ))
124124        self .assertGreater (len (output ), 0 )  # At minimum, should not hang 
125+         self .assertIn ("MemoryError" , output )
125126
126127    @cpython_only  
127128    def  test_multiline_string_parsing (self ):
0 commit comments