8000 gh-119102: Fix REPL for dumb terminal (#119332) · python/cpython@de8f530 · GitHub
[go: up one dir, main page]

Skip to content

Commit de8f530

Browse files
authored
gh-119102: Fix REPL for dumb terminal (#119332)
The site module gets the __main__ module to get _pyrepl.__main__.
1 parent 561ff1f commit de8f530

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/site.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,12 @@ def register_readline():
523523
pass
524524

525525
def write_history():
526-
from _pyrepl.__main__ import CAN_USE_PYREPL
526+
try:
527+
# _pyrepl.__main__ is executed as the __main__ module
528+
from __main__ import CAN_USE_PYREPL
529+
except ImportError:
530+
CAN_USE_PYREPL = False
531+
527532
try:
528533
if os.getenv("PYTHON_BASIC_REPL") or not CAN_USE_PYREPL:
529534
readline.write_history_file(history)

0 commit comments

Comments
 (0)
0