From 83418f36f0ba03a4be0dfc5a357d075101335949 Mon Sep 17 00:00:00 2001 From: Locked-chess-official <13140752715@163.com> Date: Sun, 19 Oct 2025 17:34:40 +0800 Subject: [PATCH] remove __package__, __file__, __spec__ in locals() --- Lib/asyncio/__main__.py | 6 +++--- .../Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst diff --git a/Lib/asyncio/__main__.py b/Lib/asyncio/__main__.py index d078ebfa4cedbe..43ba1c3b556652 100644 --- a/Lib/asyncio/__main__.py +++ b/Lib/asyncio/__main__.py @@ -191,9 +191,9 @@ def interrupt(self) -> None: asyncio.set_event_loop(loop) repl_locals = {'asyncio': asyncio} - for key in {'__name__', '__package__', - '__loader__', '__spec__', - '__builtins__', '__file__'}: + for key in {'__name__', + '__loader__', + '__builtins__'}: repl_locals[key] = locals()[key] 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..aec5ad27a47cd2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-10-19-17-34-07.gh-issue-140326.kZM0pV.rst @@ -0,0 +1 @@ +Disable relative import in asyncio repl