Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add _PyFrame_GetComplete/_PyThreadState_GetFrame
  • Loading branch information
brandtbucher committed Dec 29, 2022
commit 04b77acc91c0214a1d4a1deb4ef76b327b2a2c6b
15 changes: 15 additions & 0 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ _PyFrame_IsIncomplete(_PyInterpreterFrame *frame)
frame->prev_instr < _PyCode_CODE(frame->f_code) + frame->f_code->_co_firsttraceable;
}

static inline _PyInterpreterFrame *
_PyFrame_GetComplete(_PyInterpreterFrame *frame)
Copy link
Copy Markdown
Member

@markshannon markshannon Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name gives no sense of traversing the stack until a complete frame is found.
Maybe _PyFrame_GetFirstComplete()?

{
while (frame && _PyFrame_IsIncomplete(frame)) {
frame = frame->previous;
}
return frame;
}

static inline _PyInterpreterFrame *
_PyThreadState_GetFrame(PyThreadState *tstate)
{
return _PyFrame_GetComplete(tstate->cframe->current_frame);
}

/* For use by _PyFrame_GetFrameObject
Do not call directly. */
PyFrameObject *
Expand Down