@@ -203,24 +203,22 @@ def test_run_module_bug1764407(self):
203203
204204 @support .cpython_only
205205 def test_null_byte_in_interactive_mode (self ):
206- # gh-140594: heap-buffer-underflow в PyOS_StdioReadline при \0 в интерактивном вводе
207- env = os .environ .copy ()
208- env .pop ('PYTHONSTARTUP' , None )
209- args = [sys .executable , '-I' , '-S' , '-q' , '-i' ]
210- p = subprocess .Popen (
211- args ,
212- stdin = subprocess .PIPE ,
213- stdout = subprocess .PIPE ,
214- stderr = subprocess .STDOUT ,
215- )
216- out , _ = p .communicate (b'\x00 ' , timeout = 10 )
217- self .assertEqual (
218- p .returncode , 0 ,
219- msg = f"Interpreter aborted on NUL input, output:\n { out [:500 ]!r} "
220- )
221- if out :
222- self .assertNotIn (b'AddressSanitizer' , out )
223- self .assertNotIn (b'ERROR:' , out )
206+ # gh-140594: heap-buffer-underflow in PyOS_StdioReadline when a NUL (\0) is present in interactive input
207+ with os_helper .EnvironmentVarGuard () as env :
208+ env .unset ('PYTHONSTARTUP' )
209+ args = [sys .executable , '-I' , '-S' , '-q' , '-i' ]
210+ p = subprocess .Popen (
211+ args ,
212+ stdin = subprocess .PIPE ,
213+ stdout = subprocess .PIPE ,
214+ stderr = subprocess .STDOUT ,
215+ env = env .copy (),
216+ )
217+ out , _ = p .communicate (b'\x00 ' , timeout = 10 )
218+ self .assertEqual (
219+ p .returncode , 0 ,
220+ msg = f"Interpreter aborted on NUL input, output:\n { out [:500 ]!r} "
221+ )
224222
225223 def test_relativedir_bug46421 (self ):
226224 # Test `python -m unittest` with a relative directory beginning with ./
0 commit comments