@@ -203,24 +203,15 @@ 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 in PyOS_StdioReadline when a NUL (\0) is present in interactive input
207- with os_helper .EnvironmentVarGuard () as env :
208- env .unset ('PYTHONSTARTUP' )
209- # -I: isolated mode (ignore env vars, no user site-packages)
210- # -i: interactive mode (required to trigger the bug)
211- args = [sys .executable , '-I' , '-i' ]
212- p = subprocess .Popen (
213- args ,
214- stdin = subprocess .PIPE ,
215- stdout = subprocess .PIPE ,
216- stderr = subprocess .STDOUT ,
217- env = env .copy (),
218- )
219- out , _ = p .communicate (b'\x00 ' , timeout = 10 )
220- self .assertEqual (
221- p .returncode , 0 ,
222- msg = f"Interpreter aborted on NUL input, output:\n { out [:500 ]!r} "
223- )
206+ # gh-140594: heap-buffer-underflow in PyOS_StdioReadline when a NUL (\0)
207+ # is present in interactive input. The test ensures that feeding a null
208+ # byte to the interactive prompt does not crash the interpreter.
209+ proc = spawn_python ('-I' , '-i' )
210+ out , _ = proc .communicate (b'\x00 ' , timeout = 10 )
211+ self .assertEqual (
212+ proc .returncode , 0 ,
213+ msg = f"Interpreter aborted on NUL input, output:\n { out [:500 ]!r} "
214+ )
224215
225216 def test_relativedir_bug46421 (self ):
226217 # Test `python -m unittest` with a relative directory beginning with ./
0 commit comments