mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-127495: Append to history file after every statement in PyREPL (GH-132294)
This commit is contained in:
parent
614d79231d
commit
276252565c
4 changed files with 47 additions and 1 deletions
|
@ -30,8 +30,9 @@ import functools
|
|||
import os
|
||||
import sys
|
||||
import code
|
||||
import warnings
|
||||
|
||||
from .readline import _get_reader, multiline_input
|
||||
from .readline import _get_reader, multiline_input, append_history_file
|
||||
|
||||
|
||||
_error: tuple[type[Exception], ...] | type[Exception]
|
||||
|
@ -144,6 +145,10 @@ def run_multiline_interactive_console(
|
|||
input_name = f"<python-input-{input_n}>"
|
||||
more = console.push(_strip_final_indent(statement), filename=input_name, _symbol="single") # type: ignore[call-arg]
|
||||
assert not more
|
||||
try:
|
||||
append_history_file()
|
||||
except (FileNotFoundError, PermissionError, OSError) as e:
|
||||
warnings.warn(f"failed to open the history file for writing: {e}")
|
||||
input_n += 1
|
||||
except KeyboardInterrupt:
|
||||
r = _get_reader()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue