]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135593)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 16 Jun 2025 23:59:30 +0000 (01:59 +0200)
committerGitHub <noreply@github.com>
Mon, 16 Jun 2025 23:59:30 +0000 (23:59 +0000)
commit2b1c0a76dc56f382620d609aa7a704243b1b93cd
tree834aeffc772fd89e6e29218151bdff3a9cda7645
parent7aeddeaf93affef04eec267536ac60969ad67b94
[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>
Include/internal/pycore_ceval.h
Lib/test/test_interpreters/test_api.py
Objects/object.c
Python/bltinmodule.c
Python/ceval.c
Python/crossinterp_data_lookup.h
Python/import.c