https://github.com/python/cpython/commit/fb64db25f3a970feb6d96101ea00176d0e9ff648 commit: fb64db25f3a970feb6d96101ea00176d0e9ff648 branch: main author: Locked-chess-official <[email protected]> committer: kumaraditya303 <[email protected]> date: 2026-07-24T14:39:57Z summary:
gh-140326: disable the relative import in asyncio REPL (#140327) Co-authored-by: Kumar Aditya <[email protected]> files: A Misc/NEWS.d/next/Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst M Lib/asyncio/__main__.py diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index 708fdd595971e8..cbb052630d71ce 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -212,11 +212,14 @@ def interrupt(self) -> None: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) - repl_locals = {'asyncio': asyncio} - for key in {'__name__', '__package__', - '__loader__', '__spec__', - '__builtins__', '__file__'}: - repl_locals[key] = locals()[key] + repl_locals = { + 'asyncio': asyncio, + '__name__': __name__, + '__package__': None, + '__loader__': __loader__, + '__spec__': None, + '__builtins__': __builtins__, + } console = AsyncIOInteractiveConsole(repl_locals, loop) diff --git a/Misc/NEWS.d/next/Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst b/Misc/NEWS.d/next/Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst new file mode 100644 index 00000000000000..07eea563ea5fbc --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst @@ -0,0 +1,3 @@ +Fix the :mod:`asyncio` REPL namespace so that relative imports no longer +resolve against the :mod:`asyncio` package and ``__file__`` is no longer +set. _______________________________________________ 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]
