https://github.com/python/cpython/commit/498a94c198e72525b8a7f4cb4f4a8957560f593a
commit: 498a94c198e72525b8a7f4cb4f4a8957560f593a
branch: main
author: Marta Gómez Macías <[email protected]>
committer: ambv <[email protected]>
date: 2024-07-16T01:38:54+02:00
summary:

gh-121295: Fix blocked console after interrupting a long paste (GH-121815)

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2024-07-15-20-03-29.gh-issue-121295.w53ucI.rst
M Lib/_pyrepl/simple_interact.py

diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py
index 30a128a1218384..2c3dffe070c629 100644
--- a/Lib/_pyrepl/simple_interact.py
+++ b/Lib/_pyrepl/simple_interact.py
@@ -157,7 +157,15 @@ def maybe_run_command(statement: str) -> bool:
             assert not more
             input_n += 1
         except KeyboardInterrupt:
-            console.write("KeyboardInterrupt\n")
+            r = _get_reader()
+            if r.last_command and 'isearch' in r.last_command.__name__:
+                r.isearch_direction = ''
+                r.console.forgetinput()
+                r.pop_input_trans()
+                r.dirty = True
+            r.refresh()
+            r.in_bracketed_paste = False
+            console.write("\nKeyboardInterrupt\n")
             console.resetbuffer()
         except MemoryError:
             console.write("\nMemoryError\n")
diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2024-07-15-20-03-29.gh-issue-121295.w53ucI.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-15-20-03-29.gh-issue-121295.w53ucI.rst
new file mode 100644
index 00000000000000..7fca7d5461d39b
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-15-20-03-29.gh-issue-121295.w53ucI.rst
@@ -0,0 +1,2 @@
+Fix PyREPL console getting into a blocked state after interrupting a long
+paste

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to