https://github.com/python/cpython/commit/a310b3a99d05e107963023a5736b67afe4ae1968
commit: a310b3a99d05e107963023a5736b67afe4ae1968
branch: main
author: yihong <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-10-09T15:24:52Z
summary:

gh-139845: do not print twice in default asyncio REPL (#139846)

Co-authored-by: Kumar Aditya <[email protected]>

files:
A Misc/NEWS.d/next/Library/2025-10-09-21-37-20.gh-issue-139845.dzx5UP.rst
M Lib/asyncio/__main__.py

diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py
index 12d6f7714ee4f4..10bfca3cf96b3e 100644
--- a/Lib/asyncio/__main__.py
+++ b/Lib/asyncio/__main__.py
@@ -74,7 +74,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.

_______________________________________________
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