From 6213a512bf42464e35ae5090358b80aaa64904cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= Date: Mon, 22 Dec 2025 08:05:15 +0100 Subject: [PATCH 1/2] gh-143046: Make asyncio REPL respect the `-q` flag (quiet mode) (#143047) --- Lib/asyncio/__main__.py | 17 +++++++++-------- Lib/test/test_repl.py | 6 ++++++ ...25-12-21-17-44-28.gh-issue-143046.GBa5Ip.rst | 2 ++ 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-12-21-17-44-28.gh-issue-143046.GBa5Ip.rst diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index 89d456b6858c07..afbb70bbcab930 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 042aa84b35dcf8..0fa1df40e44c5f 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. From 39608781437e3ab9b3be88bfdb99ac0e4ac78576 Mon Sep 17 00:00:00 2001 From: Yongtao Huang Date: Mon, 22 Dec 2025 18:16:50 +0800 Subject: [PATCH 2/2] Remove unreachable code in mmapmodule error path on Windows (GH-143063) mmapmodule: remove unreachable code in Windows error path Remove an unreachable `return NULL` after `PyErr_SetFromWindowsErr()` in the Windows mmap resize error path. Signed-off-by: Yongtao Huang --- Modules/mmapmodule.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index ea20fb29c90228..0928ea6a8b70ba 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -963,7 +963,6 @@ mmap_mmap_resize_impl(mmap_object *self, Py_ssize_t new_size) if (error) { return PyErr_SetFromWindowsErr(error); - return NULL; } /* It's possible for a resize to fail, typically because another mapping is still held against the same underlying file. Even if nothing has