diff --git a/bindings/python/wrapper_top.c b/bindings/python/wrapper_top.c index 22d20c9a..1d160da4 100644 --- a/bindings/python/wrapper_top.c +++ b/bindings/python/wrapper_top.c @@ -739,6 +739,13 @@ lasso_python_log(const char *domain, GLogLevelFlags log_level, const gchar *mess G_GNUC_UNUSED gpointer user_data) { PyObject *logger_object = get_logger_object(domain), *result; + + if (PyErr_Occurred()) { + PyErr_Print(); + PyErr_Clear(); + return; + } + char *method = NULL; if (! logger_object) { @@ -773,4 +780,9 @@ lasso_python_log(const char *domain, GLogLevelFlags log_level, const gchar *mess } else { PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "lasso could not call method %s on its logger", method); } + /* clear any exception emitted during log call */ + if (PyErr_Occurred()) { + PyErr_Print(); + } + PyErr_Clear(); }