]> granicus.if.org Git - python/commitdiff
Issue #22906: Do incref before SetCause/SetContext
authorYury Selivanov <yselivanov@sprymix.com>
Sun, 10 May 2015 19:09:46 +0000 (15:09 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Sun, 10 May 2015 19:09:46 +0000 (15:09 -0400)
Objects/genobject.c

index 149e545ec066c7b78098e693789c2b615c205785..82b629cfea85a12ebdc0436292f89d8b5ce6e60a 100644 (file)
@@ -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);
         }
     }