Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-118908: Limit exposed globals from internal imports and definitions on new REPL startup#119547

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pablogsal merged 19 commits intopython:mainfromeugenetriguba:gh-118908
Jun 11, 2024

Conversation

eugenetriguba
Copy link
Contributor

@eugenetrigubaeugenetriguba commentedMay 25, 2024
edited
Loading

Currently, we expose some of the internal imports and definitions on REPL startup in the new REPL.

% ./python.exePython 3.14.0a0 (heads/main:de19694cfb, May 25 2024, 07:36:35) [Clang 15.0.0 (clang-1500.3.9.4)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> dir()['CAN_USE_PYREPL', '__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'interactive_console', 'os', 'sys']

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 onlyinteractive_console in addition to the dunder attributes shown in the global scope on startup.

% ./python.exePython 3.14.0a0 (heads/main:de19694cfb, May 25 2024, 07:36:35) [Clang 15.0.0 (clang-1500.3.9.4)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> dir()['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'interactive_console']

@eugenetrigubaeugenetriguba changed the titlegh-118908: Limit exposed globals in new REPLgh-118908: Limit exposed globals from internal imports and definitions on new REPL startupMay 25, 2024
Copy link
Member

@pablogsalpablogsal left a 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:

mainmodule=mainmoduleor__main__

And to use a clean one when it makes sense (when not running with -i) or filtering the stuff we don't want.

@bedevere-app
Copy link

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 phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ambvambv added the topic-replRelated to the interactive shell labelMay 31, 2024
@pablogsalpablogsal added the needs backport to 3.13bugs and security fixes labelJun 11, 2024
Copy link
Member

@lysnikolaoulysnikolaou left a 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.

Copy link
Member

@lysnikolaoulysnikolaou left a 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!

Copy link
Member

@lysnikolaoulysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!

@pablogsalpablogsal merged commit86a8a1c intopython:mainJun 11, 2024
40 of 41 checks passed
@miss-islington-app
Copy link

Thanks@eugenetriguba for the PR, and@pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 11, 2024
…nitions on new REPL startup (pythonGH-119547)(cherry picked from commit86a8a1c)Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com>
@bedevere-app
Copy link

GH-120362 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJun 11, 2024
pablogsal pushed a commit that referenced this pull requestJun 11, 2024
@eugenetriguba
Copy link
ContributorAuthor

@pablogsal Been a bit busy and was unable to get back to this, thank you for finishing it off and the feedback 🙂

@encukou
Copy link
Member

Since this commit, the "AMD64 Debian PGO 3.x" buildbot has started reporting a runaway process, e.g.here:

1:17:07 load avg: 20.12 [453/478/1] test_pyrepl failed (env changed) (37.4 sec)test_empty (test.test_pyrepl.test_input.KeymapTranslatorTests.test_empty) ... oktest_push_character_key (test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_character_key) ... oktest_push_character_key_with_stack (test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_character_key_with_stack) ... ok[...]test_exposed_globals_in_repl (test.test_pyrepl.test_pyrepl.TestMain.test_exposed_globals_in_repl) ... skipped 'pyrepl not available'[...]----------------------------------------------------------------------Ran 116 tests in 35.634sOK (skipped=2)Warning -- reap_children() reaped child process 3457256== Tests result: ENV CHANGED then ENV CHANGED ==

mrahtz pushed a commit to mrahtz/cpython that referenced this pull requestJun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@danielhollasdanielhollasdanielhollas left review comments

@pablogsalpablogsalpablogsal approved these changes

@lysnikolaoulysnikolaoulysnikolaou approved these changes

@ambvambvAwaiting requested review from ambvambv is a code owner

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrently

Assignees
No one assigned
Labels
topic-replRelated to the interactive shell
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@eugenetriguba@encukou@danielhollas@pablogsal@lysnikolaou@ambv

[8]ページ先頭

©2009-2025 Movatter.jp