bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C … · python/cpython@f877b40 · GitHub
Skip to content

Commit f877b40

Browse files
authored
bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API (GH-32054)
Move the private _PyFrameEvalFunction type, and private _PyInterpreterState_GetEvalFrameFunc() and _PyInterpreterState_SetEvalFrameFunc() functions to the internal C API. The _PyFrameEvalFunction callback function type now uses the _PyInterpreterFrame type which is part of the internal C API. Update the _PyFrameEvalFunction documentation.
1 parent b9a5522 commit f877b40

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

Doc/c-api/init.rst

Lines changed: 10 additions & 1 deletion

Doc/whatsnew/3.11.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,12 @@ Porting to Python 3.11
11021102
is part of the internal C API.
11031103
(Contributed by Victor Stinner in :issue:`46850`.)
11041104

1105+
* Move the private ``_PyFrameEvalFunction`` type, and private
1106+
``_PyInterpreterState_GetEvalFrameFunc()`` and
1107+
``_PyInterpreterState_SetEvalFrameFunc()`` functions to the internal C API.
1108+
The ``_PyFrameEvalFunction`` callback function type now uses the
1109+
``_PyInterpreterFrame`` type which is part of the internal C API.
1110+
(Contributed by Victor Stinner in :issue:`46850`.)
11051111

11061112
Deprecated
11071113
----------

Include/cpython/pystate.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,6 @@ PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
259259
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
260260
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
261261

262-
/* Frame evaluation API */
263-
264-
typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _PyInterpreterFrame *, int);
265-
266-
PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
267-
PyInterpreterState *interp);
268-
PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
269-
PyInterpreterState *interp,
270-
_PyFrameEvalFunction eval_frame);
271-
272262
PyAPI_FUNC(const PyConfig*) _PyInterpreterState_GetConfig(PyInterpreterState *interp);
273263

274264
/* Get a copy of the current interpreter configuration.

Include/internal/pycore_interp.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ extern "C" {
1717
#include "pycore_dict.h" // struct _Py_dict_state
1818
#include "pycore_exceptions.h" // struct _Py_exc_state
1919
#include "pycore_floatobject.h" // struct _Py_float_state
20+
#include "pycore_gc.h" // struct _gc_runtime_state
2021
#include "pycore_genobject.h" // struct _Py_async_gen_state
2122
#include "pycore_gil.h" // struct _gil_runtime_state
22-
#include "pycore_gc.h" // struct _gc_runtime_state
2323
#include "pycore_list.h" // struct _Py_list_state
2424
#include "pycore_tuple.h" // struct _Py_tuple_state
2525
#include "pycore_typeobject.h" // struct type_cache
@@ -71,6 +71,20 @@ struct atexit_state {
7171
};
7272

7373

74+
/* Frame evaluation API (PEP 523) */
75+
76+
typedef PyObject* (*_PyFrameEvalFunction) (
77+
PyThreadState *tstate,
78+
struct _PyInterpreterFrame *frame,
79+
int throwflag);
80+
81+
PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
82+
PyInterpreterState *interp);
83+
PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
84+
PyInterpreterState *interp,
85+
_PyFrameEvalFunction eval_frame);
86+
87+
7488
/* interpreter state */
7589

7690
/* PyInterpreterState holds the global state for one of the runtime's

Include/internal/pycore_pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
#include "pycore_runtime.h" /* PyRuntimeState */
11+
#include "pycore_runtime.h" // _PyRuntime
1212

1313

1414
/* Check if the current thread is the main thread.
Lines changed: 6 additions & 0 deletions

0 commit comments

Comments
 (0)