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

Skip to content

Commit 18c30a2

Browse files
committed
Issue #22906: Do incref before SetCause/SetContext
1 parent 582d3fb commit 18c30a2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Objects/genobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc)
149149
"generator raised StopIteration");
150150
PyErr_Fetch(&exc, &val2, &tb);
151151
PyErr_NormalizeException(&exc, &val2, &tb);
152+
Py_INCREF(val);
152153
PyException_SetCause(val2, val);
153154
PyException_SetContext(val2, val);
154-
Py_INCREF(val);
155155
PyErr_Restore(exc, val2, tb);
156156
}
157157
}

0 commit comments

Comments
 (0)