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() diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-01-03-10-28-31.gh-issue-127073.r8-flH.rst b/Misc/NEWS.d/next/Tools-Demos/2025-01-03-10-28-31.gh-issue-127073.r8-flH.rst new file mode 100644 index 00000000000000..680e2f25f517b8 --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2025-01-03-10-28-31.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.