ref: 11c46c8ef58f946086e295a21f2235c9eb88c125
parent: 8bfef308c4143ba57559a4cce7ecee6a0afe1f76
author: Paul Brossier <piem@piem.org>
date: Tue Mar 26 11:22:37 EDT 2019
[py] digital_filter.set_* raise ValueError (see #gh-241)
--- a/python/ext/py-filter.c
+++ b/python/ext/py-filter.c
@@ -159,6 +159,11 @@
if (PyErr_Occurred() == NULL) {
PyErr_SetString (PyExc_ValueError,
"error when setting filter to C-weighting");
+ } else {
+ // change the RuntimeError into ValueError
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ PyErr_Restore(PyExc_ValueError, value, traceback);
}
return NULL;
}
@@ -179,6 +184,11 @@
if (PyErr_Occurred() == NULL) {
PyErr_SetString (PyExc_ValueError,
"error when setting filter to A-weighting");
+ } else {
+ // change the RuntimeError into ValueError
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ PyErr_Restore(PyExc_ValueError, value, traceback);
}
return NULL;
}
@@ -199,6 +209,11 @@
if (PyErr_Occurred() == NULL) {
PyErr_SetString (PyExc_ValueError,
"error when setting filter with biquad coefficients");
+ } else {
+ // change the RuntimeError into ValueError
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ PyErr_Restore(PyExc_ValueError, value, traceback);
}
return NULL;
}