shithub: aubio

Download patch

ref: 9b23815ef6b80c6bdea50649cbd97f831b12bb31
parent: 4bc10e20d16aaaefc7d6b4942a666facddd8e090
author: Paul Brossier <piem@piem.org>
date: Tue Oct 30 09:19:53 EDT 2018

[py] use aubio_log message when set by failed aubio_<>_set_<>

--- a/python/lib/gen_code.py
+++ b/python/lib/gen_code.py
@@ -480,7 +480,14 @@
   err = aubio_{shortname}_set_{param} (self->o, {param});
 
   if (err > 0) {{
-    PyErr_SetString (PyExc_ValueError, "error running aubio_{shortname}_set_{param}");
+    if (PyErr_Occurred() == NULL) {{
+      PyErr_SetString (PyExc_ValueError, "error running aubio_{shortname}_set_{param}");
+    }} else {{
+      // change the RuntimeError into ValueError
+      PyObject *type, *value, *traceback;
+      PyErr_Fetch(&type, &value, &traceback);
+      PyErr_Restore(PyExc_ValueError, value, traceback);
+    }}
     return NULL;
   }}
   Py_RETURN_NONE;