srd: Add/use SRD_API/SRD_PRIV macros.
[libsigrokdecode.git] / exception.c
index 07ffab35969770851f941cc0d1bd0a8effac81f1..1f30c80d95a440b2a8ab7c62fb08e1d24bc463bd 100644 (file)
@@ -24,8 +24,7 @@
 #include <glib.h>
 #include <frameobject.h> /* Python header not pulled in by default. */
 
-
-void catch_exception(const char *format, ...)
+SRD_PRIV void catch_exception(const char *format, ...)
 {
        PyObject *etype, *evalue, *etb, *py_str;
        PyTracebackObject *py_tb;
@@ -41,8 +40,8 @@ void catch_exception(const char *format, ...)
        PyErr_NormalizeException(&etype, &evalue, &etb);
 
        if (!(py_str = PyObject_Str(evalue))) {
-               /* Shouldn't happen */
-               srd_dbg("srd: failed to convert exception value to string");
+               /* Shouldn't happen. */
+               srd_dbg("Failed to convert exception value to string.");
                return;
        }
 
@@ -70,12 +69,12 @@ void catch_exception(const char *format, ...)
                tracestr = NULL;
                py_tb = (PyTracebackObject *) etb;
                py_str = PyUnicode_FromFormat("%U:%d in %U",
-                               py_tb->tb_frame->f_code->co_filename, py_tb->tb_frame->f_lineno,
-                               py_tb->tb_frame->f_code->co_name);
+                                       py_tb->tb_frame->f_code->co_filename,
+                                       py_tb->tb_frame->f_lineno,
+                                       py_tb->tb_frame->f_code->co_name);
                py_str_as_str(py_str, &tracestr);
                Py_DecRef(py_str);
-               g_string_printf(msg, "srd: %s in %s: %s", ename,
-                               tracestr, str);
+               g_string_printf(msg, "%s in %s: %s", ename, tracestr, str);
                srd_dbg(msg->str);
                g_free(tracestr);
        }
@@ -88,8 +87,4 @@ void catch_exception(const char *format, ...)
 
        /* Just in case. */
        PyErr_Clear();
-
-       return;
 }
-
-