summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-02-20 14:17:18 (GMT)
committerGitHub <noreply@github.com>2021-02-20 14:17:18 (GMT)
commit46496f9d12582bf11f4911ad0f23315d6f277907 (patch)
tree8382b24a5036df07fe75c59f0a45cd401d84b17a /Include
parent4233ff3ee4add287b3617f38943d01a7a6f4d7c4 (diff)
downloadcpython-46496f9d12582bf11f4911ad0f23315d6f277907.zip
cpython-46496f9d12582bf11f4911ad0f23315d6f277907.tar.gz
cpython-46496f9d12582bf11f4911ad0f23315d6f277907.tar.bz2
bpo-42990: Functions inherit current builtins (GH-24564)
The types.FunctionType constructor now inherits the current builtins if the globals dictionary has no "__builtins__" key, rather than using {"None": None} as builtins: same behavior as eval() and exec() functions. Defining a function with "def function(...): ..." in Python is not affected, globals cannot be overriden with this syntax: it also inherits the current builtins. PyFrame_New(), PyEval_EvalCode(), PyEval_EvalCodeEx(), PyFunction_New() and PyFunction_NewWithQualName() now inherits the current builtins namespace if the globals dictionary has no "__builtins__" key. * Add _PyEval_GetBuiltins() function. * _PyEval_BuiltinsFromGlobals() now uses _PyEval_GetBuiltins() if builtins cannot be found in globals. * Add tstate parameter to _PyEval_BuiltinsFromGlobals().
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_ceval.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 78a7056..f07959d 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -34,7 +34,10 @@ PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(
void _PyEval_Fini(void);
-extern PyObject *_PyEval_BuiltinsFromGlobals(PyObject *globals);
+extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate);
+extern PyObject *_PyEval_BuiltinsFromGlobals(
+ PyThreadState *tstate,
+ PyObject *globals);
static inline PyObject*