[3.13] gh-149319: Make `asyncio` REPL respect `-I` and `-E` options (GH-149405) (#154073)

picnixz <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/77a19c81f598ff1de2499eff4362b208ebb6f7ec
commit: 77a19c81f598ff1de2499eff4362b208ebb6f7ec
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: picnixz <[email protected]>
date: 2026-07-19T12:07:03+02:00
summary:

[3.13] gh-149319: Make `asyncio` REPL respect `-I` and `-E` options (GH-149405) (#154073)

gh-149319: Make `asyncio` REPL respect `-I` and `-E` options (GH-149405)
(cherry picked from commit 7f8fc07e850d7b27a220c815db8c8abd545286c3)

Co-authored-by: Jonathan Dung <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-05-06-23-13-40.gh-issue-149319.PLM93t.rst
M Lib/asyncio/__main__.py

diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py
index 2effdbc38da2561..e734be08ddaa497 100644
--- a/Lib/asyncio/__main__.py
+++ b/Lib/asyncio/__main__.py
@@ -94,7 +94,7 @@ def run(self):
 
                 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 @@ def interrupt(self) -> None:
 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
index 000000000000000..4018ec43f5a47d9
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-05-06-23-13-40.gh-issue-149319.PLM93t.rst
@@ -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.

_______________________________________________
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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.