SIGN IN SIGN UP

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

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 a450a0ddec, AKA gh-135491)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
M
Miss Islington (bot) committed
2b1c0a76dc56f382620d609aa7a704243b1b93cd
Parent: 7aeddea
Committed by GitHub <noreply@github.com> on 6/16/2025, 11:59:30 PM