mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-40421: Add PyFrame_GetCode() function (GH-19757)
PyFrame_GetCode(frame): return a borrowed reference to the frame code. Replace frame->f_code with PyFrame_GetCode(frame) in most code, except in frameobject.c, genobject.c and ceval.c. Also add PyFrame_GetLineNumber() to the limited C API.
This commit is contained in:
parent
b8f704d219
commit
a42ca74fa3
12 changed files with 58 additions and 25 deletions
|
@ -1222,3 +1222,10 @@ _PyFrame_DebugMallocStats(FILE *out)
|
|||
numfree, sizeof(PyFrameObject));
|
||||
}
|
||||
|
||||
|
||||
PyCodeObject *
|
||||
PyFrame_GetCode(PyFrameObject *frame)
|
||||
{
|
||||
assert(frame != NULL);
|
||||
return frame->f_code;
|
||||
}
|
||||
|
|
|
@ -8033,13 +8033,13 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
PyFrameObject *f;
|
||||
PyCodeObject *co;
|
||||
Py_ssize_t i, n;
|
||||
f = _PyThreadState_GET()->frame;
|
||||
f = PyThreadState_GetFrame(_PyThreadState_GET());
|
||||
if (f == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"super(): no current frame");
|
||||
return -1;
|
||||
}
|
||||
co = f->f_code;
|
||||
co = PyFrame_GetCode(f);
|
||||
if (co == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"super(): no code object");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue