-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New REPL does not include globals from executed module when used with -i
#120678
Comments
It seems the new REPL doesn't get executed in the
>>> Foo
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
Foo
NameError: name 'Foo' is not defined >>> import sys
>>> from _pyrepl.simple_interact import run_multiline_interactive_console
>>> run_multiline_interactive_console(sys.modules['__main__'])
>>> Foo
<class '__main__.Foo'>
>>> dir()
['CAN_USE_PYREPL', 'Foo', '__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'interactive_console', 'os', 'sys'] This can be addressed in "Lib/_pyrepl/__main__.py". All imports and assignments in that module (e.g. |
I marked #120798 as a duplicate of this issue. |
This is a regression that was caused by #119547. |
…120904) Co-authored-by: Łukasz Langa <[email protected]>
pythonGH-120904) (cherry picked from commit ac07451) Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
…i` (GH-120904) (#121916) (cherry picked from commit ac07451) Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
…onGH-121924) (cherry picked from commit 19cbf8f) Co-authored-by: Łukasz Langa <[email protected]>
This is solved now, thanks everyone! |
Bug report
Bug description:
If I have a module called
foo
.py with the following contents in the root of my CPython local clone:Then running
PYTHON_BASIC_REPL=1 ./python.exe -i foo.py
, I get the following behaviour:foo.py
is executed, and theFoo
class is available in the globals of the REPL:But with the new REPL, the
Foo
class isn't available!CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
-i
#120904-i
(GH-120904) #121916The text was updated successfully, but these errors were encountered: