From: Yury Selivanov Date: Sun, 10 May 2015 19:09:46 +0000 (-0400) Subject: Issue #22906: Do incref before SetCause/SetContext X-Git-Tag: v3.5.0b1~214^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18c30a29f86dc41f96a572b6ec3f7bd6824f6e6a;p=python Issue #22906: Do incref before SetCause/SetContext --- diff --git a/Objects/genobject.c b/Objects/genobject.c index 149e545ec0..82b629cfea 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -149,9 +149,9 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc) "generator raised StopIteration"); PyErr_Fetch(&exc, &val2, &tb); PyErr_NormalizeException(&exc, &val2, &tb); + Py_INCREF(val); PyException_SetCause(val2, val); PyException_SetContext(val2, val); - Py_INCREF(val); PyErr_Restore(exc, val2, tb); } }