https://github.com/python/cpython/commit/de8f530841b55885b919677a6938ab33d4a92f20
commit: de8f530841b55885b919677a6938ab33d4a92f20
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-05-21T20:33:52Z
summary:

gh-119102: Fix REPL for dumb terminal (#119332)

The site module gets the __main__ module to get _pyrepl.__main__.

files:
M Lib/site.py

diff --git a/Lib/site.py b/Lib/site.py
index 4ba078388a37b8..f1a6d9cf66fdc3 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)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to