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:
Victor Stinner 2020-04-28 19:01:31 +02:00 committed by GitHub
parent b8f704d219
commit a42ca74fa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 58 additions and 25 deletions

View file

@ -346,7 +346,7 @@ tracemalloc_get_frame(PyFrameObject *pyframe, frame_t *frame)
lineno = 0;
frame->lineno = (unsigned int)lineno;
code = pyframe->f_code;
code = PyFrame_GetCode(pyframe);
if (code == NULL) {
#ifdef TRACE_DEBUG
tracemalloc_error("failed to get the code object of the frame");