From a42ca74fa30227e2f89a619332557cf093a937d5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 28 Apr 2020 19:01:31 +0200 Subject: 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. --- Objects/frameobject.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Objects/frameobject.c') diff --git a/Objects/frameobject.c b/Objects/frameobject.c index d0a15e7751..92206c5f52 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1222,3 +1222,10 @@ _PyFrame_DebugMallocStats(FILE *out) numfree, sizeof(PyFrameObject)); } + +PyCodeObject * +PyFrame_GetCode(PyFrameObject *frame) +{ + assert(frame != NULL); + return frame->f_code; +} -- cgit v1.2.1