From 37dc15728b36ea82be048fa80867b25182fc0823 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 20 May 2024 16:54:22 -0400 Subject: [PATCH] gh-119102: Fix REPL for dumb terminal Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide if _pyrepl.write_history_file() can be used. --- Lib/site.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/site.py b/Lib/site.py index b63447d6673f68..4ba078388a37b8 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -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)