From: Bert Vermeulen Date: Sun, 15 Jan 2012 03:24:15 +0000 (+0100) Subject: srd: handle missing module docstrings better X-Git-Tag: libsigrokdecode-0.1.0~138 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e7edca072b38affaa80dec93d21ba19a1fbd257e;p=libsigrokdecode.git srd: handle missing module docstrings better --- 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; }