summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/simple_interact.py
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2025-04-27 13:32:37 (GMT)
committerGitHub <noreply@github.com>2025-04-27 13:32:37 (GMT)
commit276252565ccfcbc6408abcbcbe6af7c56eea1e10 (patch)
tree22c3429b816b8d0372756a8736fef080bf161113 /Lib/_pyrepl/simple_interact.py
parent614d79231d1e60d31b9452ea2afbc2a7d2f0034b (diff)
downloadcpython-276252565ccfcbc6408abcbcbe6af7c56eea1e10.zip
cpython-276252565ccfcbc6408abcbcbe6af7c56eea1e10.tar.gz
cpython-276252565ccfcbc6408abcbcbe6af7c56eea1e10.tar.bz2
gh-127495: Append to history file after every statement in PyREPL (GH-132294)
Diffstat (limited to 'Lib/_pyrepl/simple_interact.py')
-rw-r--r--Lib/_pyrepl/simple_interact.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py
index a08546a..4c74466 100644
--- a/Lib/_pyrepl/simple_interact.py
+++ b/Lib/_pyrepl/simple_interact.py
@@ -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()