Skip to content

python -m asyncio does not respect PYTHON_BASIC_REPL=1 #140002

@provinzkraut

Description

@provinzkraut

Bug report

Bug description:

When using python -m asyncio, the REPL does not respect PYTHON_BASIC_REPL=1.

Using a test case from the pyrepl test suite, we can clearly see pyrepl is being used:

# The site module must not load _pyrepl if PYTHON_BASIC_REPL is set
commands = ("import sys\n"
"print('_pyrepl' in sys.modules)\n"
"exit()\n")
env["PYTHON_BASIC_REPL"] = "1"

PYTHON_BASIC_REPL=1 python -m asyncio 
asyncio REPL 3.15.0a0 (heads/main:81959a0364, Oct 12 2025, 12:47:58) [GCC 13.3.0] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> import sys
>>> '_pyrepl' in sys.modules
True

Looking at the source of asyncio.__main__, this makes perfect sense, as the asyncio REPL is a customised version of _pyrepl.console.InteractiveColoredConsole:

from _pyrepl.console import InteractiveColoredConsole
from . import futures
class AsyncIOInteractiveConsole(InteractiveColoredConsole):

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions