-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-118908: Limit exposed globals from internal imports and definitions on new REPL startup #119547
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @eugenetriguba but unfortunately I don't think this is the proper fix for this issue. The proper fix is to properly filter the namespace here:
cpython/Lib/_pyrepl/simple_interact.py
Line 122 in b407ad3
mainmodule = mainmodule or __main__ |
And to use a clean one when it makes sense (when not running with -i) or filtering the stuff we don't want.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🎉
Just a couple of comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one final comment and this is good to go! Thanks both!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks @eugenetriguba for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…nitions on new REPL startup (pythonGH-119547) (cherry picked from commit 86a8a1c) Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com>
GH-120362 is a backport of this pull request to the 3.13 branch. |
@pablogsal Been a bit busy and was unable to get back to this, thank you for finishing it off and the feedback 🙂 |
Since this commit, the "AMD64 Debian PGO 3.x" buildbot has started reporting a runaway process, e.g. here:
|
…nitions on new REPL startup (python#119547)
…nitions on new REPL startup (python#119547)
…nitions on new REPL startup (python#119547)
Currently, we expose some of the internal imports and definitions on REPL startup in the new REPL.
This PR addresses that by moving the implementation of main into its own separate module and only importing in what is needed to get it running. Now, we see there is only
interactive_console
in addition to the dunder attributes shown in the global scope on startup.