gh-126332: Fix pyrepl crash for double ctrl-z in line overflow (#126650)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
Pieter Eendebak 2025-01-21 21:14:10 +01:00 committed by GitHub
parent f18b226492
commit d147e5e52c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View file

@ -329,6 +329,20 @@ class WindowsConsoleTests(TestCase):
def erase_in_line(self):
return ERASE_IN_LINE.encode("utf8")
def test_multiline_ctrl_z(self):
# see gh-126332
code = "abcdefghi"
events = itertools.chain(
code_to_events(code),
[
Event(evt="key", data='\x1a', raw=bytearray(b'\x1a')),
Event(evt="key", data='\x1a', raw=bytearray(b'\x1a')),
],
)
reader, _ = self.handle_events_narrow(events)
self.assertEqual(reader.cxy, (2, 3))
if __name__ == "__main__":
unittest.main()