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

Lines changed: 0 additions & 10 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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()

0 commit comments

Comments
 (0)