From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 21 May 2024 13:46:11 +0000 (+0200) Subject: [3.13] gh-119102: Fix REPL for dumb terminal (GH-119269) (#119308) X-Git-Tag: v3.13.0b2~170 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f028451d95d5a8bda0ca1726b05c87a2caace025;p=thirdparty%2FPython%2Fcpython.git [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 73f4a58d36b65ec650e8f00b2affc4a4d3195f0c) Co-authored-by: Victor Stinner --- diff --git a/Lib/site.py b/Lib/site.py index b63447d6673f..4ba078388a37 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)