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");
+ } else {
+ // change the RuntimeError into ValueError
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ Py_XDECREF(type);
+ type = PyExc_ValueError;
+ Py_XINCREF(type);
+ PyErr_Restore(type, value, traceback);
+ }
return NULL;
}
Py_RETURN_NONE;
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");
+ } else {
+ // change the RuntimeError into ValueError
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ Py_XDECREF(type);
+ type = PyExc_ValueError;
+ Py_XINCREF(type);
+ PyErr_Restore(type, value, traceback);
+ }
return NULL;
}
Py_RETURN_NONE;
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");
+ } else {
+ // change the RuntimeError into ValueError
+ PyObject *type, *value, *traceback;
+ PyErr_Fetch(&type, &value, &traceback);
+ Py_XDECREF(type);
+ type = PyExc_ValueError;
+ Py_XINCREF(type);
+ PyErr_Restore(type, value, traceback);
+ }
return NULL;
}
Py_RETURN_NONE;