Skip to content

Commit c494fb3

Browse files
authored
gh-106320: Remove private _PyEval function (#108433)
Move private _PyEval functions to the internal C API (pycore_ceval.h): * _PyEval_GetBuiltin() * _PyEval_GetBuiltinId() * _PyEval_GetSwitchInterval() * _PyEval_MakePendingCalls() * _PyEval_SetProfile() * _PyEval_SetSwitchInterval() * _PyEval_SetTrace() No longer export most of these functions.
1 parent 995f4c4 commit c494fb3

19 files changed

+37
-12
lines changed

Include/cpython/ceval.h

-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,16 @@
44

55
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
66
PyAPI_FUNC(void) PyEval_SetProfileAllThreads(Py_tracefunc, PyObject *);
7-
PyAPI_FUNC(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
87
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
98
PyAPI_FUNC(void) PyEval_SetTraceAllThreads(Py_tracefunc, PyObject *);
10-
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
119

12-
/* Helper to look up a builtin object */
13-
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltin(PyObject *);
14-
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
1510
/* Look at the current frame's (if any) code's co_flags, and turn on
1611
the corresponding compiler flags in cf->cf_flags. Return 1 if any
1712
flag was set, else return 0. */
1813
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
1914

2015
PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc);
2116

22-
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
23-
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
24-
25-
PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *);
26-
2717
PyAPI_FUNC(Py_ssize_t) PyUnstable_Eval_RequestCodeExtraIndex(freefunc);
2818
// Old name -- remove when this API changes:
2919
_Py_DEPRECATED_EXTERNALLY(3.12) static inline Py_ssize_t

Include/internal/pycore_ceval.h

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ extern "C" {
1515
struct pyruntimestate;
1616
struct _ceval_runtime_state;
1717

18+
// Export for '_lsprof' shared extension
19+
PyAPI_FUNC(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
20+
21+
extern int _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
22+
23+
// Helper to look up a builtin object
24+
// Export for 'array' shared extension
25+
PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *);
26+
27+
extern PyObject* _PyEval_GetBuiltinId(_Py_Identifier *);
28+
29+
extern void _PyEval_SetSwitchInterval(unsigned long microseconds);
30+
extern unsigned long _PyEval_GetSwitchInterval(void);
31+
32+
// Export for '_queue' shared extension
33+
PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *);
34+
1835
#ifndef Py_DEFAULT_RECURSION_LIMIT
1936
# define Py_DEFAULT_RECURSION_LIMIT 1000
2037
#endif

Modules/_lsprof.c

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "Python.h"
66
#include "pycore_call.h" // _PyObject_CallNoArgs()
7+
#include "pycore_ceval.h" // _PyEval_SetProfile()
78
#include "pycore_pystate.h" // _PyThreadState_GET()
89
#include "rotatingtree.h"
910

Modules/_queuemodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#endif
44

55
#include "Python.h"
6+
#include "pycore_ceval.h" // _PyEval_MakePendingCalls()
67
#include "pycore_moduleobject.h" // _PyModule_GetState()
78
#include "pycore_time.h" // _PyTime_t
89

Modules/_threadmodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* Interface to Sjoerd's portable C thread library */
44

55
#include "Python.h"
6+
#include "pycore_ceval.h" // _PyEval_MakePendingCalls()
67
#include "pycore_interp.h" // _PyInterpreterState.threads.count
78
#include "pycore_moduleobject.h" // _PyModule_GetState()
89
#include "pycore_pylifecycle.h"

Modules/arraymodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Python.h"
1111
#include "pycore_bytesobject.h" // _PyBytes_Repeat
1212
#include "pycore_call.h" // _PyObject_CallMethod()
13+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
1314
#include "pycore_long.h" // _PyLong_FromByteArray()
1415
#include "pycore_moduleobject.h" // _PyModule_GetState()
1516

Modules/itertoolsmodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Python.h"
22
#include "pycore_call.h" // _PyObject_CallNoArgs()
3+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
34
#include "pycore_long.h" // _PyLong_GetZero()
45
#include "pycore_moduleobject.h" // _PyModule_GetState()
56
#include "pycore_typeobject.h" // _PyType_GetModuleState()

Objects/bytearrayobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "pycore_abstract.h" // _PyIndex_Check()
55
#include "pycore_bytes_methods.h"
66
#include "pycore_bytesobject.h"
7+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
78
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
89
#include "pycore_strhex.h" // _Py_strhex_with_sep()
910
#include "pycore_long.h" // _PyLong_FromUnsignedChar()

Objects/bytesobject.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
#include "Python.h"
44
#include "pycore_abstract.h" // _PyIndex_Check()
5-
#include "pycore_bytesobject.h" // _PyBytes_Find(), _PyBytes_Repeat()
65
#include "pycore_bytes_methods.h" // _Py_bytes_startswith()
6+
#include "pycore_bytesobject.h" // _PyBytes_Find(), _PyBytes_Repeat()
77
#include "pycore_call.h" // _PyObject_CallNoArgs()
8+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
89
#include "pycore_format.h" // F_LJUST
9-
#include "pycore_global_objects.h" // _Py_GET_GLOBAL_OBJECT()
10+
#include "pycore_global_objects.h"// _Py_GET_GLOBAL_OBJECT()
1011
#include "pycore_initconfig.h" // _PyStatus_OK()
1112
#include "pycore_long.h" // _PyLong_DigitValue
1213
#include "pycore_object.h" // _PyObject_GC_TRACK

Objects/classobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "Python.h"
44
#include "pycore_call.h" // _PyObject_VectorcallTstate()
5+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
56
#include "pycore_object.h"
67
#include "pycore_pyerrors.h"
78
#include "pycore_pystate.h" // _PyThreadState_GET()

Objects/dictobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ As a consequence of this, split keys have a maximum size of 16.
115115
#include "Python.h"
116116
#include "pycore_bitutils.h" // _Py_bit_length
117117
#include "pycore_call.h" // _PyObject_CallNoArgs()
118+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
118119
#include "pycore_code.h" // stats
119120
#include "pycore_dict.h" // PyDictKeysObject
120121
#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED()

Objects/genericaliasobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// types.GenericAlias -- used to represent e.g. list[int].
22

33
#include "Python.h"
4+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
45
#include "pycore_object.h"
56
#include "pycore_unionobject.h" // _Py_union_type_or, _PyGenericAlias_Check
67

Objects/iterobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "Python.h"
44
#include "pycore_abstract.h" // _PyObject_HasLen()
55
#include "pycore_call.h" // _PyObject_CallNoArgs()
6+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
67
#include "pycore_object.h" // _PyObject_GC_TRACK()
78

89
typedef struct {

Objects/listobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "Python.h"
44
#include "pycore_abstract.h" // _PyIndex_Check()
5+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
56
#include "pycore_interp.h" // PyInterpreterState.list
67
#include "pycore_list.h" // struct _Py_list_state, _PyListIterObject
78
#include "pycore_long.h" // _PyLong_DigitCount

Objects/odictobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ Potential Optimizations
465465
*/
466466

467467
#include "Python.h"
468+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
468469
#include "pycore_call.h" // _PyObject_CallNoArgs()
469470
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
470471
#include "pycore_dict.h" // _Py_dict_lookup()

Objects/rangeobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "Python.h"
44
#include "pycore_abstract.h" // _PyIndex_Check()
5+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
56
#include "pycore_long.h" // _PyLong_GetZero()
67
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
78
#include "pycore_range.h"

Objects/setobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
#include "Python.h"
35+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
3536
#include "pycore_dict.h" // _PyDict_Contains_KnownHash()
3637
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
3738
#include "pycore_object.h" // _PyObject_GC_UNTRACK()

Objects/tupleobject.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "Python.h"
55
#include "pycore_abstract.h" // _PyIndex_Check()
6+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
67
#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED()
78
#include "pycore_initconfig.h" // _PyStatus_OK()
89
#include "pycore_modsupport.h" // _PyArg_NoKwnames()

Objects/unicodeobject.c

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4343
#include "pycore_atomic_funcs.h" // _Py_atomic_size_get()
4444
#include "pycore_bytes_methods.h" // _Py_bytes_lower()
4545
#include "pycore_bytesobject.h" // _PyBytes_Repeat()
46+
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
4647
#include "pycore_codecs.h" // _PyCodec_Lookup()
4748
#include "pycore_format.h" // F_LJUST
4849
#include "pycore_initconfig.h" // _PyStatus_OK()
@@ -56,6 +57,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5657
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
5758
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
5859
#include "pycore_unicodeobject_generated.h" // _PyUnicode_InitStaticStrings()
60+
5961
#include "stringlib/eq.h" // unicode_eq()
6062
#include <stddef.h> // ptrdiff_t
6163

0 commit comments

Comments
 (0)