]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-140251: colorize import statement formatting in asyncio console (#140252)
authorFrost Ming <mianghong@gmail.com>
Sat, 18 Oct 2025 14:35:24 +0000 (22:35 +0800)
committerGitHub <noreply@github.com>
Sat, 18 Oct 2025 14:35:24 +0000 (20:05 +0530)
Lib/asyncio/__main__.py
Misc/NEWS.d/next/Library/2025-10-17-12-33-01.gh-issue-140251.esM-OX.rst [new file with mode: 0644]

index 10bfca3cf96b3e71e5adbd3d2708c412a350d8fe..d078ebfa4cedbe406fe1dbe2ff3234ca9a9c9b41 100644 (file)
@@ -107,7 +107,10 @@ class REPLThread(threading.Thread):
             if CAN_USE_PYREPL:
                 theme = get_theme().syntax
                 ps1 = f"{theme.prompt}{ps1}{theme.reset}"
-            console.write(f"{ps1}import asyncio\n")
+                import_line = f'{theme.keyword}import{theme.reset} asyncio'
+            else:
+                import_line = "import asyncio"
+            console.write(f"{ps1}{import_line}\n")
 
             if CAN_USE_PYREPL:
                 from _pyrepl.simple_interact import (
diff --git a/Misc/NEWS.d/next/Library/2025-10-17-12-33-01.gh-issue-140251.esM-OX.rst b/Misc/NEWS.d/next/Library/2025-10-17-12-33-01.gh-issue-140251.esM-OX.rst
new file mode 100644 (file)
index 0000000..cb08e02
--- /dev/null
@@ -0,0 +1 @@
+Colorize the default import statement ``import asyncio`` in asyncio REPL.