From ddfc155d3ade5f4867c6789136df73f61d4efb03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20S=C5=82awecki?= Date: Thu, 18 Dec 2025 14:00:12 +0100 Subject: [PATCH] gh-142784: make the asyncio REPL call `loop.close()` at exit (#142785) --- Lib/asyncio/__main__.py | 1 + .../Library/2025-12-16-04-39-27.gh-issue-142784.HBGJag.rst | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-12-16-04-39-27.gh-issue-142784.HBGJag.rst diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index d078ebfa4ced..89d456b6858c 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -240,4 +240,5 @@ if __name__ == '__main__': break console.write('exiting asyncio REPL...\n') + loop.close() sys.exit(return_code) diff --git a/Misc/NEWS.d/next/Library/2025-12-16-04-39-27.gh-issue-142784.HBGJag.rst b/Misc/NEWS.d/next/Library/2025-12-16-04-39-27.gh-issue-142784.HBGJag.rst new file mode 100644 index 000000000000..92a723cbc297 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-12-16-04-39-27.gh-issue-142784.HBGJag.rst @@ -0,0 +1,3 @@ +The :mod:`asyncio` REPL now properly closes the loop upon the end of interactive session. +Previously, it could cause surprising warnings. +Contributed by Bartosz Sławecki. -- 2.47.3