bpo-40421: Add pyframe.h header file (GH-19755)
Add a new separated pyframe.h header file of the PyFrame public C
API: it is included by Python.h.
Add PyFrame_GetLineNumber() to the limited C API.
Replace "struct _frame" with "PyFrameObject" in header files.
PyFrameObject is now defined as struct _frame by pyframe.h which is
included early enough in Python.h.
diff --git a/Include/cpython/ceval.h b/Include/cpython/ceval.h
index 020f787..e1922a6 100644
--- a/Include/cpython/ceval.h
+++ b/Include/cpython/ceval.h
@@ -23,7 +23,7 @@
flag was set, else return 0. */
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
-PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _frame *f, int exc);
+PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int exc);
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
diff --git a/Include/cpython/frameobject.h b/Include/cpython/frameobject.h
index 4ced967..e819cef 100644
--- a/Include/cpython/frameobject.h
+++ b/Include/cpython/frameobject.h
@@ -14,7 +14,7 @@
int b_level; /* value stack level to pop to */
} PyTryBlock;
-typedef struct _frame {
+struct _frame {
PyObject_VAR_HEAD
struct _frame *f_back; /* previous frame, or NULL */
PyCodeObject *f_code; /* code segment */
@@ -44,7 +44,7 @@
char f_executing; /* whether the frame is still executing */
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
-} PyFrameObject;
+};
/* Standard object interface */
@@ -79,9 +79,6 @@
PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out);
-/* Return the line of code the frame is currently executing. */
-PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
-
#ifdef __cplusplus
}
#endif
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 9b28f66..f292da1 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -16,7 +16,7 @@
/* State unique per thread */
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
-typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
+typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
/* The following values are used for 'what' for tracefunc functions
*
@@ -56,7 +56,7 @@
PyInterpreterState *interp;
/* Borrowed reference to the current frame (it can be NULL) */
- struct _frame *frame;
+ PyFrameObject *frame;
int recursion_depth;
char overflowed; /* The stack has overflowed. Allow 50 more calls
to handle the runtime error. */
@@ -184,7 +184,7 @@
/* Frame evaluation API */
-typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _frame *, int);
+typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, PyFrameObject *, int);
PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
PyInterpreterState *interp);
diff --git a/Include/cpython/traceback.h b/Include/cpython/traceback.h
index 746097d..837470c 100644
--- a/Include/cpython/traceback.h
+++ b/Include/cpython/traceback.h
@@ -9,7 +9,7 @@
typedef struct _traceback {
PyObject_HEAD
struct _traceback *tb_next;
- struct _frame *tb_frame;
+ PyFrameObject *tb_frame;
int tb_lasti;
int tb_lineno;
} PyTracebackObject;