diff options
-rw-r--r-- | src/dmidecodemodule.c | 4 | ||||
-rw-r--r-- | src/xmlpythonizer.c | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c index fc3a7ed..14ff148 100644 --- a/src/dmidecodemodule.c +++ b/src/dmidecodemodule.c @@ -256,7 +256,9 @@ static PyObject *dmidecode_get(PyObject *self, const char *section) } mapping = dmiMAP_ParseMappingXML(opt.mappingxml, section); - assert( mapping != NULL ); + if( mapping == NULL ) { + return NULL; + } // Generate Python dict out of XML node pydata = pythonizeXMLnode(mapping, dmixml_n); diff --git a/src/xmlpythonizer.c b/src/xmlpythonizer.c index 6287ea2..3c00f6b 100644 --- a/src/xmlpythonizer.c +++ b/src/xmlpythonizer.c @@ -243,13 +243,13 @@ ptzMAP *dmiMAP_ParseMappingXML(xmlDoc *xmlmap, const char *mapname) { // Verify that the root node got the right name if( (node == NULL) || (xmlStrcmp(node->name, (xmlChar *) "dmidecode_fieldmap") != 0 )) { - fprintf(stderr, "Invalid XML-Python mapping file\n"); + PyErr_SetString(PyExc_IOError, "Invalid XML-Python mapping file"); return NULL; } // Verify that it's of a version we support if( strcmp(dmixml_GetAttrValue(node, "version"), "1") != 0 ) { - fprintf(stderr, "Unsupported XML-Python mapping file format\n"); + PyErr_SetString(PyExc_IOError, "Unsupported XML-Python mapping file format"); return NULL; } @@ -264,8 +264,10 @@ ptzMAP *dmiMAP_ParseMappingXML(xmlDoc *xmlmap, const char *mapname) { } if( node == NULL ) { - fprintf(stderr, "No mapping for '%s' was found " - "in the XML-Python mapping file\n", mapname); + char msg[8194]; + snprintf(msg, 8193, "No mapping for '%s' was found " + "in the XML-Python mapping file%c", mapname, 0); + PyErr_SetString(PyExc_IOError, msg); return NULL; } |