Skip to content

bpo-46850: Move private _PyEval functions to internal C API #31532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1025,3 +1025,21 @@ Removed
* Remove the ``HAVE_PY_SET_53BIT_PRECISION`` macro (moved to the internal C
API).
(Contributed by Victor Stinner in :issue:`45412`.)

* Remove the following ``_PyEval`` private functions (moved to the internal C
API headers):

* ``_PyEval_CallTracing()``
* ``_PyEval_EvalFrameDefault()``
* ``_PyEval_GetAsyncGenFinalizer()``
* ``_PyEval_GetAsyncGenFirstiter()``
* ``_PyEval_GetCoroutineOriginTrackingDepth()``
* ``_PyEval_GetSwitchInterval()``
* ``_PyEval_RequestCodeExtraIndex()``
* ``_PyEval_SetAsyncGenFinalizer()``
* ``_PyEval_SetAsyncGenFirstiter()``
* ``_PyEval_SetProfile()``
* ``_PyEval_SetSwitchInterval()``
* ``_PyEval_SetTrace()``

(Contributed by Victor Stinner in :issue:`46850`.)
17 changes: 1 addition & 16 deletions Include/cpython/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,17 @@
# error "this header file must not be included directly"
#endif

PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);

PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
PyAPI_FUNC(int) _PyEval_SetAsyncGenFirstiter(PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
PyAPI_FUNC(int) _PyEval_SetAsyncGenFinalizer(PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFinalizer(void);

/* Helper to look up a builtin object */
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltin(PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);

/* Look at the current frame's (if any) code's co_flags, and turn on
the corresponding compiler flags in cf->cf_flags. Return 1 if any
flag was set, else return 0. */
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);

PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _interpreter_frame *f, int exc);

PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);

PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);

PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
17 changes: 17 additions & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ struct _ceval_runtime_state;
#include "pycore_pystate.h" // _PyThreadState_GET()


PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
PyAPI_FUNC(int) _PyEval_SetAsyncGenFirstiter(PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
PyAPI_FUNC(int) _PyEval_SetAsyncGenFinalizer(PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFinalizer(void);

PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _interpreter_frame *f, int exc);

PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);

PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);


extern void _Py_FinishPendingCalls(PyThreadState *tstate);
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);
Expand Down
17 changes: 17 additions & 0 deletions Misc/NEWS.d/next/C API/2022-02-24-16-39-59.bpo-46850.mQcF8i.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Remove the following ``_PyEval`` private functions (moved to the internal C
API headers):

* ``_PyEval_CallTracing()``
* ``_PyEval_EvalFrameDefault()``
* ``_PyEval_GetAsyncGenFinalizer()``
* ``_PyEval_GetAsyncGenFirstiter()``
* ``_PyEval_GetCoroutineOriginTrackingDepth()``
* ``_PyEval_GetSwitchInterval()``
* ``_PyEval_RequestCodeExtraIndex()``
* ``_PyEval_SetAsyncGenFinalizer()``
* ``_PyEval_SetAsyncGenFirstiter()``
* ``_PyEval_SetProfile()``
* ``_PyEval_SetSwitchInterval()``
* ``_PyEval_SetTrace()``

Patch by Victor Stinner.
1 change: 1 addition & 0 deletions Modules/_lsprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _PyEval_SetProfile()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "rotatingtree.h"

Expand Down