[py] incref exception type before restoring it
authorPaul Brossier <piem@piem.org>
Sat, 29 Jun 2019 10:48:56 +0000 (12:48 +0200)
committerPaul Brossier <piem@piem.org>
Sat, 29 Jun 2019 10:48:56 +0000 (12:48 +0200)
python/lib/gen_code.py

index b48f9a0..3db270b 100644 (file)
@@ -509,7 +509,10 @@ Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)
       // change the RuntimeError into ValueError
       PyObject *type, *value, *traceback;
       PyErr_Fetch(&type, &value, &traceback);
-      PyErr_Restore(PyExc_ValueError, value, traceback);
+      Py_XDECREF(type);
+      type = PyExc_ValueError;
+      Py_XINCREF(type);
+      PyErr_Restore(type, value, traceback);
     }}
     return NULL;
   }}