]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-127960 Fix the REPL to set the correct namespace by setting the correct `__main__...
authorYuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
Thu, 22 May 2025 00:18:00 +0000 (19:18 -0500)
committerGitHub <noreply@github.com>
Thu, 22 May 2025 00:18:00 +0000 (02:18 +0200)
commitb1b8962443e7d418601658a4b05347a5a9161910
tree9ecb32485011e518b2cb55fa7c944451231591b9
parenta66bae8bb52721ea597ade6222f83876f9e939ba
gh-127960 Fix the REPL to set the correct namespace by setting the correct `__main__` module (gh-134275)

The `__main__` module imported in the `_pyrepl` module points to the `_pyrepl` module itself when the interpreter was launched without `-m` option and didn't execute a module,
while it's an unexpected behavior that `__main__` can be `_pyrepl` and relative imports such as `from . import *` works based on the `_pyrepl` module.

Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Lib/_pyrepl/_module_completer.py
Lib/_pyrepl/main.py
Lib/_pyrepl/readline.py
Lib/test/support/__init__.py
Lib/test/test_pyrepl/test_pyrepl.py
Misc/NEWS.d/next/Core_and_Builtins/2025-05-21-18-02-56.gh-issue-127960.W3J_2X.rst [new file with mode: 0644]
Modules/main.c