diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-22 00:14:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-22 00:14:44 (GMT) |
commit | f371565169438c3b93763f298d5171985607ab5d (patch) | |
tree | 282fe2c98475f63c255858e4f5e5c1e390944ecb /Lib | |
parent | 05820164cecdd377474ebcf3a69eaefac27fc329 (diff) | |
download | cpython-f371565169438c3b93763f298d5171985607ab5d.zip cpython-f371565169438c3b93763f298d5171985607ab5d.tar.gz cpython-f371565169438c3b93763f298d5171985607ab5d.tar.bz2 |
[3.13] gh-119102: Fix REPL for dumb terminal (GH-119332) (#119359)
The site module gets the __main__ module to get _pyrepl.__main__.
(cherry picked from commit de8f530841b55885b919677a6938ab33d4a92f20)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib')
-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) |