mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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>
This commit is contained in:
parent
28efeefab7
commit
c1600c78e4
3 changed files with 115 additions and 90 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue