From 7055c48b236f6f86c1ceba5b986baa3b11f30437 Mon Sep 17 00:00:00 2001 From: Marta Gomez Macias Date: Mon, 15 Jul 2024 20:01:52 +0000 Subject: [PATCH 1/3] fix: Blocked console after interrupting a long paste --- Lib/_pyrepl/simple_interact.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index bc16c1f6a23159..1cb5b6febb5019 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -154,7 +154,15 @@ def more_lines(unicodetext: str) -> bool: assert not more input_n += 1 except KeyboardInterrupt: - console.write("KeyboardInterrupt\n") + r = _get_reader() + if '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") From e7a57dadd8c2521202bee88b2f16c6168b2b4206 Mon Sep 17 00:00:00 2001 From: Marta Gomez Macias Date: Mon, 15 Jul 2024 20:03:36 +0000 Subject: [PATCH 2/3] Add news entry --- .../2024-07-15-20-03-29.gh-issue-121295.w53ucI.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2024-07-15-20-03-29.gh-issue-121295.w53ucI.rst 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 From 4060650ce35e189244fa2a01577c8981e15638f4 Mon Sep 17 00:00:00 2001 From: Marta Gomez Macias Date: Mon, 15 Jul 2024 20:12:32 +0000 Subject: [PATCH 3/3] fix mypi bug --- Lib/_pyrepl/simple_interact.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index 1cb5b6febb5019..d173eb714a6bdb 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -155,7 +155,7 @@ def more_lines(unicodetext: str) -> bool: input_n += 1 except KeyboardInterrupt: r = _get_reader() - if 'isearch' in r.last_command.__name__: + if r.last_command and 'isearch' in r.last_command.__name__: r.isearch_direction = '' r.console.forgetinput() r.pop_input_trans()