gh-111201: Speed up paste mode in the REPL (#119341)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Pablo Galindo Salgado 2024-05-22 01:28:32 -04:00 committed by GitHub
parent cd516cd1f5
commit e6572e8f98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 16 deletions

View file

@ -328,7 +328,7 @@ class _ReadlineWrapper:
reader.ps1 = str(prompt)
return reader.readline(startup_hook=self.startup_hook)
def multiline_input(self, more_lines: MoreLinesCallable, ps1: str, ps2: str) -> tuple[str, bool]:
def multiline_input(self, more_lines: MoreLinesCallable, ps1: str, ps2: str) -> str:
"""Read an input on possibly multiple lines, asking for more
lines as long as 'more_lines(unicodetext)' returns an object whose
boolean value is true.
@ -337,14 +337,15 @@ class _ReadlineWrapper:
saved = reader.more_lines
try:
reader.more_lines = more_lines
reader.ps1 = reader.ps2 = ps1
reader.ps3 = reader.ps4 = ps2
reader.ps1 = ps1
reader.ps2 = ps1
reader.ps3 = ps2
reader.ps4 = ""
with warnings.catch_warnings(action="ignore"):
return reader.readline(), reader.was_paste_mode_activated
return reader.readline()
finally:
reader.more_lines = saved
reader.paste_mode = False
reader.was_paste_mode_activated = False
def parse_and_bind(self, string: str) -> None:
pass # XXX we don't support parsing GNU-readline-style init files