https://github.com/python/cpython/commit/10a3d431881bb9169abde97f85ea6a670e1ef3cc
commit: 10a3d431881bb9169abde97f85ea6a670e1ef3cc
branch: main
author: Peter Bierma <[email protected]>
committer: encukou <[email protected]>
date: 2025-06-26T11:43:08+02:00
summary:
gh-135755: Move `PyFunction_GET_BUILTINS` to the private API (GH-135938)
files:
M Include/cpython/funcobject.h
M Include/internal/pycore_function.h
M Modules/_testinternalcapi.c
M Objects/funcobject.c
diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h
index 18249b95befe65..598cd330bc9ca9 100644
--- a/Include/cpython/funcobject.h
+++ b/Include/cpython/funcobject.h
@@ -97,11 +97,6 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject
*func) {
}
#define PyFunction_GET_GLOBALS(func)
PyFunction_GET_GLOBALS(_PyObject_CAST(func))
-static inline PyObject* PyFunction_GET_BUILTINS(PyObject *func) {
- return _PyFunction_CAST(func)->func_builtins;
-}
-#define PyFunction_GET_BUILTINS(func)
PyFunction_GET_BUILTINS(_PyObject_CAST(func))
-
static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
return _PyFunction_CAST(func)->func_module;
}
diff --git a/Include/internal/pycore_function.h
b/Include/internal/pycore_function.h
index a30d52d49bdc4d..6e1209659565a3 100644
--- a/Include/internal/pycore_function.h
+++ b/Include/internal/pycore_function.h
@@ -41,6 +41,11 @@ extern PyObject *_Py_set_function_type_params(
PyAPI_FUNC(int)
_PyFunction_VerifyStateless(PyThreadState *, PyObject *);
+static inline PyObject* _PyFunction_GET_BUILTINS(PyObject *func) {
+ return _PyFunction_CAST(func)->func_builtins;
+}
+#define _PyFunction_GET_BUILTINS(func)
_PyFunction_GET_BUILTINS(_PyObject_CAST(func))
+
#ifdef __cplusplus
}
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 804cb4e4d1c8ee..fdf22a0c994d3a 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -21,6 +21,7 @@
#include "pycore_fileutils.h" // _Py_normpath()
#include "pycore_flowgraph.h" // _PyCompile_OptimizeCfg()
#include "pycore_frame.h" // _PyInterpreterFrame
+#include "pycore_function.h" // _PyFunction_GET_BUILTINS
#include "pycore_gc.h" // PyGC_Head
#include "pycore_hashtable.h" // _Py_hashtable_new()
#include "pycore_import.h" // _PyImport_ClearExtension()
@@ -1022,7 +1023,7 @@ get_code_var_counts(PyObject *self, PyObject *_args,
PyObject *_kwargs)
globalsns = PyFunction_GET_GLOBALS(codearg);
}
if (builtinsns == NULL) {
- builtinsns = PyFunction_GET_BUILTINS(codearg);
+ builtinsns = _PyFunction_GET_BUILTINS(codearg);
}
codearg = PyFunction_GET_CODE(codearg);
}
@@ -1190,7 +1191,7 @@ verify_stateless_code(PyObject *self, PyObject *args,
PyObject *kwargs)
globalsns = PyFunction_GET_GLOBALS(codearg);
}
if (builtinsns == NULL) {
- builtinsns = PyFunction_GET_BUILTINS(codearg);
+ builtinsns = _PyFunction_GET_BUILTINS(codearg);
}
codearg = PyFunction_GET_CODE(codearg);
}
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index f87b0e5d8f1e47..f8dd10a346d613 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -1256,7 +1256,7 @@ _PyFunction_VerifyStateless(PyThreadState *tstate,
PyObject *func)
return -1;
}
// Check the builtins.
- PyObject *builtinsns = PyFunction_GET_BUILTINS(func);
+ PyObject *builtinsns = _PyFunction_GET_BUILTINS(func);
if (builtinsns != NULL && !PyDict_Check(builtinsns)) {
_PyErr_Format(tstate, PyExc_TypeError,
"unsupported builtins %R", builtinsns);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]