[3.13] gh-119102: Fix REPL for dumb terminal (GH-119269) (#119308)

gh-119102: Fix REPL for dumb terminal (GH-119269)

Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide
if _pyrepl.write_history_file() can be used.
(cherry picked from commit 73f4a58d36)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2024-05-21 15:46:11 +02:00 committed by GitHub
parent 49ad4d077f
commit f028451d95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -523,8 +523,9 @@ def register_readline():
pass
def write_history():
from _pyrepl.__main__ import CAN_USE_PYREPL
try:
if os.getenv("PYTHON_BASIC_REPL"):
if os.getenv("PYTHON_BASIC_REPL") or not CAN_USE_PYREPL:
readline.write_history_file(history)
else:
_pyrepl.readline.write_history_file(history)