From 4e75c2aced080d9d3c043af208c99ce3378709dd Mon Sep 17 00:00:00 2001 From: Tongjun Gao Date: Sat, 4 Jan 2025 09:23:09 +0800 Subject: [PATCH 1/2] Clear completion list when KeyboardInterrupt occurs Previously, the completion list would persist after a KeyboardInterrupt was triggered. This change ensures the completion state is properly reset. --- Lib/_pyrepl/simple_interact.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index a5033496712a73..0d84a70ad6ab3e 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -164,6 +164,8 @@ def maybe_run_command(statement: str) -> bool: r = _get_reader() if r.input_trans is r.isearch_trans: r.do_cmd(("isearch-end", [""])) + if r.cmpltn_menu_choices: + r.cmpltn_reset() r.pos = len(r.get_unicode()) r.dirty = True r.refresh() From cbe2f11233c2a3cf497b856954eb6764a545810f Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:45:20 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2025-01-04-01-45-19.gh-issue-127073.r8-flH.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Tools-Demos/2025-01-04-01-45-19.gh-issue-127073.r8-flH.rst diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-01-04-01-45-19.gh-issue-127073.r8-flH.rst b/Misc/NEWS.d/next/Tools-Demos/2025-01-04-01-45-19.gh-issue-127073.r8-flH.rst new file mode 100644 index 00000000000000..680e2f25f517b8 --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2025-01-04-01-45-19.gh-issue-127073.r8-flH.rst @@ -0,0 +1,4 @@ +Previously in the REPL, when a completion list was displayed and KeyboardInterrupt +was triggered using Ctrl+C, the completion list would persist and duplicate with +each KeyboardInterrupt. Now, when KeyboardInterrupt occurs, the completion list +is properly cleared, consistent with the behavior of other errors.