summaryrefslogtreecommitdiffstats
path: root/src/dmidecodemodule.c
diff options
context:
space:
mode:
authorNima Talebi <nima@autonomy.net.au>2009-05-24 00:26:23 +1000
committerNima Talebi <nima@autonomy.net.au>2009-05-24 00:26:23 +1000
commitaf27ba4dd2ffdef8e4ee3abf187475c1b3303f71 (patch)
treee81421584332fb363e7b5ba22fecd585b083226e /src/dmidecodemodule.c
parent6b1598c8b98699b115525155b43d19365e79dd08 (diff)
downloadpython-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.tar.gz
python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.tar.xz
python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.zip
Completed preliminary reimplementation of type()
Updated test unit to match. Throw an exception instead of returning None/False in some functions.
Diffstat (limited to 'src/dmidecodemodule.c')
-rw-r--r--src/dmidecodemodule.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c
index 1b56837..82f2de7 100644
--- a/src/dmidecodemodule.c
+++ b/src/dmidecodemodule.c
@@ -360,6 +360,8 @@ static PyObject *dmidecode_get_slot(PyObject * self, PyObject * args)
static PyObject *dmidecode_get_type(PyObject * self, PyObject * args)
{
long unsigned int lu;
+ char msg[8194];
+ int e = 0;
if(PyArg_ParseTuple(args, (char *)"i", &lu)) {
if(lu < 256) {
@@ -368,9 +370,17 @@ static PyObject *dmidecode_get_type(PyObject * self, PyObject * args)
sprintf(s, "%lu", lu);
return dmidecode_get(self, s);
}
- return Py_False;
+ e = 1;
+ //return Py_False;
}
- return Py_None;
+ e = 2;
+ //return Py_None;
+
+ if(e == 1) snprintf(msg, 8193, "Types are bound between 0 and 255 (inclusive)%c", 0);
+ else snprintf(msg, 8193, "Invalid type identifier%c", 0);
+
+ PyErr_SetString(PyExc_SystemError, msg);
+ return NULL;
}
static PyObject *dmidecode_dump(PyObject * self, PyObject * null)