Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for NUL byte in interactive mode
  • Loading branch information
ashm-dev committed Nov 2, 2025
commit 71d79cad8a55d8a136a6856a4309d7016701f897
21 changes: 21 additions & 0 deletions Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,27 @@ def test_run_module_bug1764407(self):
self.assertTrue(data.find(b'1 loop') != -1)
self.assertTrue(data.find(b'__main__.Timer') != -1)

@support.cpython_only
def test_null_byte_in_interactive_mode(self):
# gh-140594: heap-buffer-underflow в PyOS_StdioReadline при \0 в интерактивном вводе
Comment thread
ashm-dev marked this conversation as resolved.
Outdated
env = os.environ.copy()
env.pop('PYTHONSTARTUP', None)
Comment thread
ashm-dev marked this conversation as resolved.
Outdated
args = [sys.executable, '-I', '-S', '-q', '-i']
Comment thread
ashm-dev marked this conversation as resolved.
Outdated
p = subprocess.Popen(
args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
out, _ = p.communicate(b'\x00', timeout=10)
self.assertEqual(
p.returncode, 0,
msg=f"Interpreter aborted on NUL input, output:\n{out[:500]!r}"
)
if out:
Comment thread
ashm-dev marked this conversation as resolved.
Outdated
self.assertNotIn(b'AddressSanitizer', out)
self.assertNotIn(b'ERROR:', out)

def test_relativedir_bug46421(self):
# Test `python -m unittest` with a relative directory beginning with ./
# Note: We have to switch to the project's top module's directory, as per
Expand Down
Loading