diff options
author | Victor Stinner <vstinner@python.org> | 2024-05-21 20:33:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 20:33:52 (GMT) |
commit | de8f530841b55885b919677a6938ab33d4a92f20 (patch) | |
tree | 876eeaef0f1752b1b56322d4bdb2a7a184eaa0ab /Lib/site.py | |
parent | 561ff1fa710493dee8c6482f990bd17535b27040 (diff) | |
download | cpython-de8f530841b55885b919677a6938ab33d4a92f20.zip cpython-de8f530841b55885b919677a6938ab33d4a92f20.tar.gz cpython-de8f530841b55885b919677a6938ab33d4a92f20.tar.bz2 |
gh-119102: Fix REPL for dumb terminal (#119332)
The site module gets the __main__ module to get _pyrepl.__main__.
Diffstat (limited to 'Lib/site.py')
-rw-r--r-- | Lib/site.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py index 4ba0783..f1a6d9c 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -523,7 +523,12 @@ def register_readline(): pass def write_history(): - from _pyrepl.__main__ import CAN_USE_PYREPL + try: + # _pyrepl.__main__ is executed as the __main__ module + from __main__ import CAN_USE_PYREPL + except ImportError: + CAN_USE_PYREPL = False + try: if os.getenv("PYTHON_BASIC_REPL") or not CAN_USE_PYREPL: readline.write_history_file(history) |