diff options
author | Emily Morehouse <emily@cuttlesoft.com> | 2024-09-25 18:22:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 18:22:03 (GMT) |
commit | c1600c78e4565b6bb558ade451abe2648ba4dd0a (patch) | |
tree | bd17e1a3aa256803506e27259766493d5e24290c /Lib/_pyrepl | |
parent | 28efeefab7d577ea4fb6e3f6e82f903f2aee271d (diff) | |
download | cpython-c1600c78e4565b6bb558ade451abe2648ba4dd0a.zip cpython-c1600c78e4565b6bb558ade451abe2648ba4dd0a.tar.gz cpython-c1600c78e4565b6bb558ade451abe2648ba4dd0a.tar.bz2 |
gh-123856: Fix PyREPL failure when a keyboard interrupt is triggered after using a history search (#124396)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/_pyrepl')
-rw-r--r-- | Lib/_pyrepl/simple_interact.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py index 3c79cf6..342a4b5 100644 --- a/Lib/_pyrepl/simple_interact.py +++ b/Lib/_pyrepl/simple_interact.py @@ -28,6 +28,7 @@ from __future__ import annotations import _sitebuiltins import linecache import functools +import os import sys import code @@ -50,7 +51,9 @@ def check() -> str: try: _get_reader() except _error as e: - return str(e) or repr(e) or "unknown error" + if term := os.environ.get("TERM", ""): + term = f"; TERM={term}" + return str(str(e) or repr(e) or "unknown error") + term return "" @@ -159,10 +162,8 @@ def run_multiline_interactive_console( input_n += 1 except KeyboardInterrupt: r = _get_reader() - if r.last_command and 'isearch' in r.last_command.__name__: - r.isearch_direction = '' - r.console.forgetinput() - r.pop_input_trans() + if r.input_trans is r.isearch_trans: + r.do_cmd(("isearch-end", [""])) r.pos = len(r.get_unicode()) r.dirty = True r.refresh() |