https://github.com/python/cpython/commit/6a3b861cb2c47aa936b3e0064a9aad07f688f0e3
commit: 6a3b861cb2c47aa936b3e0064a9aad07f688f0e3
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-12-22T13:48:16+05:30
summary:

[3.14] gh-143046: Make asyncio REPL respect the `-q` flag (quiet mode) 
(GH-143047) (#143060)

gh-143046: Make asyncio REPL respect the `-q` flag (quiet mode) (GH-143047)
(cherry picked from commit 6213a512bf42464e35ae5090358b80aaa64904cc)

Co-authored-by: Bartosz SÅ‚awecki <[email protected]>

files:
A Misc/NEWS.d/next/Library/2025-12-21-17-44-28.gh-issue-143046.GBa5Ip.rst
M Lib/asyncio/__main__.py
M Lib/test/test_repl.py

diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py
index 898de0cb2eae30..64f9b3c54e4a4d 100644
--- a/Lib/asyncio/__main__.py
+++ b/Lib/asyncio/__main__.py
@@ -86,14 +86,15 @@ def run(self):
         global return_code
 
         try:
-            banner = (
-                f'asyncio REPL {sys.version} on {sys.platform}\n'
-                f'Use "await" directly instead of "asyncio.run()".\n'
-                f'Type "help", "copyright", "credits" or "license" '
-                f'for more information.\n'
-            )
-
-            console.write(banner)
+            if not sys.flags.quiet:
+                banner = (
+                    f'asyncio REPL {sys.version} on {sys.platform}\n'
+                    f'Use "await" directly instead of "asyncio.run()".\n'
+                    f'Type "help", "copyright", "credits" or "license" '
+                    f'for more information.\n'
+                )
+
+                console.write(banner)
 
             if startup_path := os.getenv("PYTHONSTARTUP"):
                 sys.audit("cpython.run_startup", startup_path)
diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py
index 58bd2b5d916858..17bc53d20c39d2 100644
--- a/Lib/test/test_repl.py
+++ b/Lib/test/test_repl.py
@@ -409,6 +409,12 @@ def test_toplevel_contextvars_async(self):
         expected = "toplevel contextvar test: ok"
         self.assertIn(expected, output, expected)
 
+    def test_quiet_mode(self):
+        p = spawn_repl("-q", "-m", "asyncio", custom=True)
+        output = kill_python(p)
+        self.assertEqual(p.returncode, 0)
+        self.assertEqual(output[:3], ">>>")
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git 
a/Misc/NEWS.d/next/Library/2025-12-21-17-44-28.gh-issue-143046.GBa5Ip.rst 
b/Misc/NEWS.d/next/Library/2025-12-21-17-44-28.gh-issue-143046.GBa5Ip.rst
new file mode 100644
index 00000000000000..ac819a47f4cde9
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-12-21-17-44-28.gh-issue-143046.GBa5Ip.rst
@@ -0,0 +1,2 @@
+The :mod:`asyncio` REPL no longer prints copyright and version messages in
+the quiet mode (:option:`-q`). Patch by Bartosz Sławecki.

_______________________________________________
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