summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-28 17:01:31 (GMT)
committerGitHub <noreply@github.com>2020-04-28 17:01:31 (GMT)
commita42ca74fa30227e2f89a619332557cf093a937d5 (patch)
treea3097e76897d8f8a0f054cab0736fd3cff80f8da /Modules/_lsprof.c
parentb8f704d2190125a7750b50cd9b67267b9c20fd43 (diff)
downloadcpython-a42ca74fa30227e2f89a619332557cf093a937d5.zip
cpython-a42ca74fa30227e2f89a619332557cf093a937d5.tar.gz
cpython-a42ca74fa30227e2f89a619332557cf093a937d5.tar.bz2
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.
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 7115fee..39cf6e1 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -1,5 +1,4 @@
#include "Python.h"
-#include "frameobject.h"
#include "rotatingtree.h"
/************************************************************/
@@ -388,14 +387,16 @@ profiler_callback(PyObject *self, PyFrameObject *frame, int what,
/* the 'frame' of a called function is about to start its execution */
case PyTrace_CALL:
- ptrace_enter_call(self, (void *)frame->f_code,
- (PyObject *)frame->f_code);
+ {
+ PyCodeObject *code = PyFrame_GetCode(frame);
+ ptrace_enter_call(self, (void *)code, (PyObject *)code);
break;
+ }
/* the 'frame' of a called function is about to finish
(either normally or with an exception) */
case PyTrace_RETURN:
- ptrace_leave_call(self, (void *)frame->f_code);
+ ptrace_leave_call(self, (void *)PyFrame_GetCode(frame));
break;
/* case PyTrace_EXCEPTION: