- /* "Import" the Python module. */
- if (!(py_mod = PyImport_ImportModule(name))) { /* NEWREF */
- PyErr_Print(); /* Returns void. */
- return SRD_ERR_PYTHON; /* TODO: More specific error? */
+ py_basedec = py_method = NULL;
+
+ srd_dbg("decoder: %s: loading module '%s'", __func__, name);
+
+ if (!(d = g_try_malloc0(sizeof(struct srd_decoder)))) {
+ srd_err("decoder: %s: d malloc failed", __func__);
+ ret = SRD_ERR_MALLOC;
+ goto err_out;
+ }
+
+ ret = SRD_ERR_PYTHON;
+
+ /* Import the Python module. */
+ if (!(d->py_mod = PyImport_ImportModule(name))) {
+ /* TODO: Report exception message/traceback to err/dbg. */
+ srd_warn("decoder: %s: import of '%s' failed", __func__, name);
+ PyErr_Print();
+ PyErr_Clear();
+ goto err_out;