I'm trying to extend the asyncio REPL (yes, I know this is an unsupported use case) by doing the following:
from asyncio.__main__ import AsyncIOInteractiveConsole
- Copy the
if __name__ == '__main__' block into my own __main__.py
- Copy and edit
REPLThread (subclassing isn't possible because it also refers to global variables)
However, this doesn't work because AsyncIOInteractiveConsole refers to asyncio.__main__'s global loop variable, despite it being passed and assigned to the instance attribute self.loop.
https://github.com/python/cpython/blob/3.13/Lib/asyncio/__main__.py#L65
I see no reason why AsyncIOInteractiveConsole shouldn't use self.loop consistently.
Linked PRs
I'm trying to extend the asyncio REPL (yes, I know this is an unsupported use case) by doing the following:
from asyncio.__main__ import AsyncIOInteractiveConsoleif __name__ == '__main__'block into my own__main__.pyREPLThread(subclassing isn't possible because it also refers to global variables)However, this doesn't work because
AsyncIOInteractiveConsolerefers toasyncio.__main__'s globalloopvariable, despite it being passed and assigned to the instance attributeself.loop.https://github.com/python/cpython/blob/3.13/Lib/asyncio/__main__.py#L65
I see no reason why
AsyncIOInteractiveConsoleshouldn't useself.loopconsistently.Linked PRs
self.loopinstead of globalloopvariable in asyncio REPL #136448self.loopinstead of globalloopvariable in asyncio REPL (GH-136448) #136457self.loopinstead of globalloopvariable in asyncio REPL (GH-136448) #136458