diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index 878b3cae4cfc77..8e9af83cc8af8f 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -72,7 +72,8 @@ def callback(): return except BaseException: if keyboard_interrupted: - self.write("\nKeyboardInterrupt\n") + if not CAN_USE_PYREPL: + self.write("\nKeyboardInterrupt\n") else: self.showtraceback() return self.STATEMENT_FAILED diff --git a/Misc/NEWS.d/next/Library/2025-10-09-21-37-20.gh-issue-139845.dzx5UP.rst b/Misc/NEWS.d/next/Library/2025-10-09-21-37-20.gh-issue-139845.dzx5UP.rst new file mode 100644 index 00000000000000..3cd294e49cdda3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-10-09-21-37-20.gh-issue-139845.dzx5UP.rst @@ -0,0 +1 @@ +Fix to not print KeyboardInterrupt twice in default asyncio REPL.