10000 gh-135755: Move `PyFunction_GET_BUILTINS` to the private API (GH-135938) · python/cpython@10a3d43 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10a3d43

Browse files
gh-135755: Move PyFunction_GET_BUILTINS to the private API (GH-135938)
1 parent a1da208 commit 10a3d43

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

Include/cpython/funcobject.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
9797
}
9898
#define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
9999

100-
static inline PyObject* PyFunction_GET_BUILTINS(PyObject *func) {
101-
return _PyFunction_CAST(func)->func_builtins;
102-
}
103-
#define PyFunction_GET_BUILTINS(func) PyFunction_GET_BUILTINS(_PyObject_CAST(func))
104-
105100
static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
106101
return _PyFunction_CAST(func)->func_module;
107102
}

Include/internal/pycore_function.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ extern PyObject *_Py_set_function_type_params(
4141
PyAPI_FUNC(int)
4242
_PyFunction_VerifyStateless(PyThreadState *, PyObject *);
4343

44+
static inline PyObject* _PyFunction_GET_BUILTINS(PyObject *func) {
45+
return _PyFunction_CAST(func)->func_builtins;
46+
}
47+
#define _PyFunction_GET_BUILTINS(func) _PyFunction_GET_BUILTINS(_PyObject_CAST(func))
48+
4449

4550
#ifdef __cplusplus
4651
}

Modules/_testinternalcapi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "pycore_fileutils.h" // _Py_normpath()
2222
#include "pycore_flowgraph.h" // _PyCompile_OptimizeCfg()
2323
#include "pycore_frame.h" // _PyInterpreterFrame
24+
#include "pycore_function.h" // _PyFunction_GET_BUILTINS
2425
#include "pycore_gc.h" // PyGC_Head
2526
#include "pycore_hashtable.h" // _Py_hashtable_new()
2627
#include "pycore_import.h" // _PyImport_ClearExtension()
@@ -1022,7 +1023,7 @@ get_code_var_counts(PyObject *self, PyObject *_args, PyObject *_kwargs)
10221023
globalsns = PyFunction_GET_GLOBALS(codearg);
10231024
}
10241025
if (builtinsns == NULL) {
1025-
builtinsns = PyFunction_GET_BUILTINS(codearg);
1026+
builtinsns = _PyFunction_GET_BUILTINS(codearg);
10261027
}
10271028
codearg = PyFunction_GET_CODE(codearg);
10281029
}
@@ -1190,7 +1191,7 @@ verify_stateless_code(PyObject *self, PyObject *args, PyObject *kwargs)
11901191
globalsns = PyFunction_GET_GLOBALS(codearg);
11911192
}
11921193
if (builtinsns == NULL) {
1193-
builtinsns = PyFunction_GET_BUILTINS(codearg);
1194+
builtinsns = _PyFunction_GET_BUILTINS(codearg);
11941195
}
11951196
codearg = PyFunction_GET_CODE(codearg);
11961197
}

Objects/funcobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ _PyFunction_VerifyStateless(PyThreadState *tstate, PyObject *func)
12561256
return -1;
12571257
}
12581258
// Check the builtins.
1259-
PyObject *builtinsns = PyFunction_GET_BUILTINS(func);
1259+
PyObject *builtinsns = _PyFunction_GET_BUILTINS(func);
12601260
if (builtinsns != NULL && !PyDict_Check(builtinsns)) {
12611261
_PyErr_Format(tstate, PyExc_TypeError,
12621262
"unsupported builtins %R", builtinsns);

0 commit comments

Comments
 (0)
0