shithub: aubio

Download patch

ref: 8bfef308c4143ba57559a4cce7ecee6a0afe1f76
parent: 22e3ef12f8264a2553fddb035992827207cd09f9
author: Paul Brossier <piem@piem.org>
date: Tue Mar 26 11:17:05 EDT 2019

[py] improve digital_filter error messages (closes #gh-241)

--- a/python/ext/py-filter.c
+++ b/python/ext/py-filter.c
@@ -156,8 +156,10 @@
 
   err = aubio_filter_set_c_weighting (self->o, samplerate);
   if (err > 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "error when setting filter to C-weighting");
+    if (PyErr_Occurred() == NULL) {
+      PyErr_SetString (PyExc_ValueError,
+          "error when setting filter to C-weighting");
+    }
     return NULL;
   }
   Py_RETURN_NONE;
@@ -174,8 +176,10 @@
 
   err = aubio_filter_set_a_weighting (self->o, samplerate);
   if (err > 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "error when setting filter to A-weighting");
+    if (PyErr_Occurred() == NULL) {
+      PyErr_SetString (PyExc_ValueError,
+          "error when setting filter to A-weighting");
+    }
     return NULL;
   }
   Py_RETURN_NONE;
@@ -192,8 +196,10 @@
 
   err = aubio_filter_set_biquad (self->o, b0, b1, b2, a1, a2);
   if (err > 0) {
-    PyErr_SetString (PyExc_ValueError,
-        "error when setting filter with biquad coefficients");
+    if (PyErr_Occurred() == NULL) {
+      PyErr_SetString (PyExc_ValueError,
+          "error when setting filter with biquad coefficients");
+    }
     return NULL;
   }
   Py_RETURN_NONE;