We cannot do anything with them here, so we need to de-fuse the
exception so that we won't run into errors when the originally called
Python function returns.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
const char* fn, const char* format, va_list args) {
PyObject* callback = (PyObject*)data;
PyObject* exception = NULL;
+ PyObject* type = NULL;
+ PyObject* value = NULL;
+ PyObject* traceback = NULL;
// Do nothing if callback isn't set
if (!callback)
occurred and if so, print it to the console.
*/
exception = PyErr_Occurred();
- if (exception)
+ if (exception) {
PyErr_Print();
+ // Fetch the exception and destroy it
+ PyErr_Fetch(&type, &value, &traceback);
+
+ Py_XDECREF(type);
+ Py_XDECREF(value);
+ Py_XDECREF(traceback);
+ }
+
if (buffer)
free(buffer);
Py_XDECREF(tuple);