mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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>
This commit is contained in:
parent
a66bae8bb5
commit
b1b8962443
7 changed files with 85 additions and 34 deletions
|
@ -17,8 +17,8 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
def make_default_module_completer() -> ModuleCompleter:
|
||||
# Inside pyrepl, __package__ is set to '_pyrepl'
|
||||
return ModuleCompleter(namespace={'__package__': '_pyrepl'})
|
||||
# Inside pyrepl, __package__ is set to None by default
|
||||
return ModuleCompleter(namespace={'__package__': None})
|
||||
|
||||
|
||||
class ModuleCompleter:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue