Skip to content

Commit 498a94c

Browse files
authored
gh-121295: Fix blocked console after interrupting a long paste (GH-121815)
1 parent 7d111da commit 498a94c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Lib/_pyrepl/simple_interact.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,15 @@ def maybe_run_command(statement: str) -> bool:
157157
assert not more
158158
input_n += 1
159159
except KeyboardInterrupt:
160-
console.write("KeyboardInterrupt\n")
160+
r = _get_reader()
161+
if r.last_command and 'isearch' in r.last_command.__name__:
162+
r.isearch_direction = ''
163+
r.console.forgetinput()
164+
r.pop_input_trans()
165+
r.dirty = True
166+
r.refresh()
167+
r.in_bracketed_paste = False
168+
console.write("\nKeyboardInterrupt\n")
161169
console.resetbuffer()
162170
except MemoryError:
163171
console.write("\nMemoryError\n")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix PyREPL console getting into a blocked state after interrupting a long
2+
paste

0 commit comments

Comments
 (0)