gh-111201: Allow pasted code to contain multiple statements in the REPL (#118712)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Pablo Galindo Salgado 2024-05-07 17:01:49 +01:00 committed by GitHub
parent 26bab423fb
commit a94ac56628
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 9 deletions

View file

@ -281,7 +281,7 @@ class InteractiveConsole(InteractiveInterpreter):
elif exitmsg != '':
self.write('%s\n' % exitmsg)
def push(self, line, filename=None):
def push(self, line, filename=None, _symbol="single"):
"""Push a line to the interpreter.
The line should not have a trailing newline; it may have
@ -299,7 +299,7 @@ class InteractiveConsole(InteractiveInterpreter):
source = "\n".join(self.buffer)
if filename is None:
filename = self.filename
more = self.runsource(source, filename)
more = self.runsource(source, filename, symbol=_symbol)
if not more:
self.resetbuffer()
return more