From: Paul Brossier Date: Fri, 10 Apr 2026 15:11:58 +0000 (-0300) Subject: [py] only set RuntimeError string when needed in gen_code.py (closes gh-303) X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=ad5cf975aed08cc4562dd008cf9f83b12b82ffb8;p=aubio.git [py] only set RuntimeError string when needed in gen_code.py (closes gh-303) --- diff --git a/python/lib/gen_code.py b/python/lib/gen_code.py index 95b9fa54..fbb06a03 100644 --- a/python/lib/gen_code.py +++ b/python/lib/gen_code.py @@ -345,7 +345,8 @@ Py_{shortname}_init (Py_{shortname} * self, PyObject * args, PyObject * kwds) out += """ // return -1 and set error string on failure if (self->o == NULL) {{ - PyErr_Format (PyExc_RuntimeError, "failed creating {shortname}"); + if (PyErr_Occurred() == NULL) + PyErr_Format (PyExc_RuntimeError, "failed creating {shortname}"); return -1; }} """.format(paramchars = paramchars, paramvals = paramvals, **self.__dict__)