bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)

The PyThreadState_GetFrame() function now returns a strong reference
to the frame.
This commit is contained in:
Victor Stinner 2020-04-29 03:01:43 +02:00 committed by GitHub
parent 37af21b667
commit 4386b9045e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 20 deletions

View file

@ -1042,11 +1042,13 @@ PyThreadState_GetInterpreter(PyThreadState *tstate)
}
struct _frame*
PyFrameObject*
PyThreadState_GetFrame(PyThreadState *tstate)
{
assert(tstate != NULL);
return tstate->frame;
PyFrameObject *frame = tstate->frame;
Py_XINCREF(frame);
return frame;
}
@ -1165,7 +1167,7 @@ _PyThread_CurrentFrames(void)
for (i = runtime->interpreters.head; i != NULL; i = i->next) {
PyThreadState *t;
for (t = i->tstate_head; t != NULL; t = t->next) {
struct _frame *frame = t->frame;
PyFrameObject *frame = t->frame;
if (frame == NULL) {
continue;
}