summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2024-06-04 21:22:28 (GMT)
committerGitHub <noreply@github.com>2024-06-04 21:22:28 (GMT)
commit69b3e8ea569faabccd74036e3d0e5ec7c0c62a20 (patch)
treed6bd0afa6a57a2db29118908b2f359dbe9874c76
parent4055577221f5f52af329e87f31d81bb8fb02c504 (diff)
downloadcpython-69b3e8ea569faabccd74036e3d0e5ec7c0c62a20.zip
cpython-69b3e8ea569faabccd74036e3d0e5ec7c0c62a20.tar.gz
cpython-69b3e8ea569faabccd74036e3d0e5ec7c0c62a20.tar.bz2
gh-119553: Fix console when pressing Ctrl-C within a multiline block (#120075)
-rw-r--r--Lib/_pyrepl/commands.py2
-rw-r--r--Lib/_pyrepl/simple_interact.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/Lib/_pyrepl/commands.py b/Lib/_pyrepl/commands.py
index e94e8c25..6bffed1 100644
--- a/Lib/_pyrepl/commands.py
+++ b/Lib/_pyrepl/commands.py
@@ -216,11 +216,13 @@ class interrupt(FinishCommand):
import signal
self.reader.console.finish()
+ self.reader.finish()
os.kill(os.getpid(), signal.SIGINT)
class ctrl_c(Command):
def do(self) -> None:
+ self.reader.console.finish()
self.reader.finish()
raise KeyboardInterrupt
diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py
index 256bbc7..2e5698e 100644
--- a/Lib/_pyrepl/simple_interact.py
+++ b/Lib/_pyrepl/simple_interact.py
@@ -149,7 +149,7 @@ def run_multiline_interactive_console(
assert not more
input_n += 1
except KeyboardInterrupt:
- console.write("\nKeyboardInterrupt\n")
+ console.write("KeyboardInterrupt\n")
console.resetbuffer()
except MemoryError:
console.write("\nMemoryError\n")