Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 21 additions & 2 deletions Lib/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,34 @@ def interact(self, banner=None, exitmsg=None):
try:
while True:
try:
received_eof = False
if more:
prompt = sys.ps2
else:
prompt = sys.ps1
try:
line = self.raw_input(prompt)
except EOFError:
self.write("\n")
break
received_eof = True
if received_eof:
if more:
source = "\n".join(self.buffer)
try:
code = self.compile.compiler(
source,
self.filename,
"single",
incomplete_input=False,
)
self.runcode(code)
self.write("\n")
except (SyntaxError, IndentationError):
self.showsyntaxerror(self.filename, source=source)
self.resetbuffer()
more = False
else:
self.write("\n")
break
else:
more = self.push(line)
except KeyboardInterrupt:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix difference in Ctrl+D handling between :func:`code.interact` and the Python
REPL. Patch by Adam Hartz
Loading