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/Objects/frameobject.c b/Objects/frameobject.c
index bdd7862..d0a15e7 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -34,10 +34,13 @@
int
PyFrame_GetLineNumber(PyFrameObject *f)
{
- if (f->f_trace)
+ assert(f != NULL);
+ if (f->f_trace) {
return f->f_lineno;
- else
+ }
+ else {
return PyCode_Addr2Line(f->f_code, f->f_lasti);
+ }
}
static PyObject *