Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.14] gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135491) #135593

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

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 16, 2025

For several builtin functions, we now fall back to main.dict for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true. This allows those functions to be run with Interpreter.call().

The affected builtins:

  • exec()
  • eval()
  • globals()
  • locals()
  • vars()
  • dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.
(cherry picked from commit a450a0d)

Co-authored-by: Eric Snow [email protected]

…pythongh-135491)

For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true.  This allows those functions to be run with Interpreter.call().

The affected builtins:

* exec()
* eval()
* globals()
* locals()
* vars()
* dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.
(cherry picked from commit a450a0d)

Co-authored-by: Eric Snow <[email protected]>
@ericsnowcurrently ericsnowcurrently enabled auto-merge (squash) June 16, 2025 23:35
@ericsnowcurrently ericsnowcurrently merged commit 2b1c0a7 into python:3.14 Jun 16, 2025
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants