summaryrefslogtreecommitdiff
path: root/decoder.c
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2012-01-15 04:24:15 +0100
committerBert Vermeulen <bert@biot.com>2012-01-15 04:24:15 +0100
commite7edca072b38affaa80dec93d21ba19a1fbd257e (patch)
tree336caf1879e75e648048b27f7753281fca506fa5 /decoder.c
parent87998e973f16206be1391f87ccae7c2756baf353 (diff)
downloadlibsigrokdecode-e7edca072b38affaa80dec93d21ba19a1fbd257e.tar.gz
libsigrokdecode-e7edca072b38affaa80dec93d21ba19a1fbd257e.zip
srd: handle missing module docstrings better
Diffstat (limited to 'decoder.c')
-rw-r--r--decoder.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/decoder.c b/decoder.c
index 6b5fc95..dde067e 100644
--- a/decoder.c
+++ b/decoder.c
@@ -193,10 +193,21 @@ err_out:
char *srd_decoder_doc(struct srd_decoder *dec)
{
+ PyObject *py_str;
char *doc;
+ if (!PyObject_HasAttrString(dec->py_mod, "__doc__"))
+ return NULL;
+
+ if (!(py_str = PyObject_GetAttrString(dec->py_mod, "__doc__"))) {
+ PyErr_Clear();
+ return NULL;
+ }
+
doc = NULL;
- py_attr_as_str(dec->py_mod, "__doc__", &doc);
+ if (py_str != Py_None)
+ py_str_as_str(py_str, &doc);
+ Py_DecRef(py_str);
return doc;
}