]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-149319: Make `asyncio` REPL respect `-I` and `-E` options (GH-149405) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 19 Jul 2026 10:07:03 +0000 (12:07 +0200)
committerGitHub <noreply@github.com>
Sun, 19 Jul 2026 10:07:03 +0000 (12:07 +0200)
gh-149319: Make `asyncio` REPL respect `-I` and `-E` options (GH-149405)
(cherry picked from commit 7f8fc07e850d7b27a220c815db8c8abd545286c3)

Co-authored-by: Jonathan Dung <jonathandung@yahoo.com>
Lib/asyncio/__main__.py
Misc/NEWS.d/next/Library/2026-05-06-23-13-40.gh-issue-149319.PLM93t.rst [new file with mode: 0644]

index 2effdbc38da2561ef50aba6de894b31610025803..e734be08ddaa49720e5b4b437350a03f866d7b72 100644 (file)
@@ -94,7 +94,7 @@ class REPLThread(threading.Thread):
 
                 console.write(banner)
 
-            if not sys.flags.isolated and (startup_path := os.getenv("PYTHONSTARTUP")):
+            if not sys.flags.ignore_environment and (startup_path := os.getenv("PYTHONSTARTUP")):
                 sys.audit("cpython.run_startup", startup_path)
                 try:
                     import tokenize
@@ -148,7 +148,7 @@ class REPLThread(threading.Thread):
 if __name__ == '__main__':
     sys.audit("cpython.run_stdin")
 
-    if os.getenv('PYTHON_BASIC_REPL'):
+    if not sys.flags.ignore_environment and os.getenv('PYTHON_BASIC_REPL'):
         CAN_USE_PYREPL = False
     else:
         from _pyrepl.main import CAN_USE_PYREPL
diff --git a/Misc/NEWS.d/next/Library/2026-05-06-23-13-40.gh-issue-149319.PLM93t.rst b/Misc/NEWS.d/next/Library/2026-05-06-23-13-40.gh-issue-149319.PLM93t.rst
new file mode 100644 (file)
index 0000000..4018ec4
--- /dev/null
@@ -0,0 +1 @@
+The :mod:`asyncio` REPL now ignores :envvar:`PYTHONSTARTUP` and :envvar:`PYTHON_BASIC_REPL` when :option:`-E` or :option:`-I` is used. Patch by Jonathan Dung.