Skip to content

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 ericsnowcurrently@gmail.com

…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 <ericsnowcurrently@gmail.com>
@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