From: Frost Ming Date: Sat, 18 Oct 2025 14:35:24 +0000 (+0800) Subject: gh-140251: colorize import statement formatting in asyncio console (#140252) X-Git-Tag: v3.15.0a2~398 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d86ad870cc112d4bd36165398368826746555730;p=thirdparty%2FPython%2Fcpython.git gh-140251: colorize import statement formatting in asyncio console (#140252) --- diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index 10bfca3cf96b..d078ebfa4ced 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -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 index 000000000000..cb08e02429b2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-10-17-12-33-01.gh-issue-140251.esM-OX.rst @@ -0,0 +1 @@ +Colorize the default import statement ``import asyncio`` in asyncio REPL.