]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-119102: Fix REPL for dumb terminal (#119269)
authorVictor Stinner <vstinner@python.org>
Tue, 21 May 2024 12:53:20 +0000 (08:53 -0400)
committerGitHub <noreply@github.com>
Tue, 21 May 2024 12:53:20 +0000 (13:53 +0100)
Use CAN_USE_PYREPL of _pyrepl.__main__ in the site module to decide
if _pyrepl.write_history_file() can be used.

Lib/site.py

index b63447d6673f68ea28a234508761d4f162291bbd..4ba078388a37b8ef7c3c401a4891efc9563cee2e 100644 (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)