From b2549d1ef13f328cde0613065c9737d8b6232ea2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 21 May 2024 19:44:51 +0200 Subject: [PATCH 1/2] gh-119102: Fix REPL for dumb terminal The site module gets the __main__ module to get _pyrepl.__main__. --- Lib/site.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/site.py b/Lib/site.py index 4ba078388a37b8..4da447cd3af8ea 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 = True + try: if os.getenv("PYTHON_BASIC_REPL") or not CAN_USE_PYREPL: readline.write_history_file(history) From eb4b00a65dedb6cddff8f410ce1617243de620aa Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 21 May 2024 19:54:41 +0200 Subject: [PATCH 2/2] Use False on ImportError --- Lib/site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/site.py b/Lib/site.py index 4da447cd3af8ea..f1a6d9cf66fdc3 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -527,7 +527,7 @@ def write_history(): # _pyrepl.__main__ is executed as the __main__ module from __main__ import CAN_USE_PYREPL except ImportError: - CAN_USE_PYREPL = True + CAN_USE_PYREPL = False try: if os.getenv("PYTHON_BASIC_REPL") or not CAN_USE_PYREPL: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy