fix some error handling
This commit is contained in:
@ -73,6 +73,7 @@ static PyObject* pyRecord_rtype(pyRecord *self)
|
|||||||
|
|
||||||
static PyObject* pyRecord_info(pyRecord *self, PyObject *args)
|
static PyObject* pyRecord_info(pyRecord *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
long ret;
|
||||||
const char *name;
|
const char *name;
|
||||||
PyObject *def = NULL;
|
PyObject *def = NULL;
|
||||||
DBENTRY entry;
|
DBENTRY entry;
|
||||||
@ -81,18 +82,16 @@ static PyObject* pyRecord_info(pyRecord *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dbCopyEntryContents(&self->entry, &entry);
|
dbCopyEntryContents(&self->entry, &entry);
|
||||||
|
ret = dbFindInfo(&entry, name);
|
||||||
|
dbFinishEntry(&entry);
|
||||||
|
|
||||||
if(dbFindInfo(&entry, name)) {
|
if(!ret)
|
||||||
if(def) {
|
return PyString_FromString(dbGetInfoString(&entry));
|
||||||
Py_INCREF(def);
|
|
||||||
return def;
|
|
||||||
} else {
|
|
||||||
PyErr_SetNone(PyExc_KeyError);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return PyString_FromString(dbGetInfoString(&entry));
|
Py_XINCREF(def);
|
||||||
|
if(!def)
|
||||||
|
PyErr_SetNone(PyExc_KeyError);
|
||||||
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* pyRecord_infos(pyRecord *self)
|
static PyObject* pyRecord_infos(pyRecord *self)
|
||||||
@ -110,19 +109,15 @@ static PyObject* pyRecord_infos(pyRecord *self)
|
|||||||
for(status = dbFirstInfo(&entry); status==0; status = dbNextInfo(&entry))
|
for(status = dbFirstInfo(&entry); status==0; status = dbNextInfo(&entry))
|
||||||
{
|
{
|
||||||
PyObject *val = PyString_FromString(dbGetInfoString(&entry));
|
PyObject *val = PyString_FromString(dbGetInfoString(&entry));
|
||||||
if(!val)
|
if(!val || PyDict_SetItemString(dict, dbGetInfoName(&entry), val)<0) {
|
||||||
goto fail;
|
Py_XDECREF(val);
|
||||||
|
Py_DECREF(dict);
|
||||||
if(PyDict_SetItemString(dict, dbGetInfoName(&entry), val)<0) {
|
dict = NULL;
|
||||||
Py_DECREF(val);
|
break;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dict;
|
return dict;
|
||||||
fail:
|
|
||||||
Py_DECREF(dict);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws)
|
static PyObject* pyRecord_setSevr(pyRecord *self, PyObject *args, PyObject *kws)
|
||||||
@ -264,13 +259,13 @@ static PyObject *pyRecord_asyncFinish(pyRecord *self, PyObject *args, PyObject *
|
|||||||
|
|
||||||
epicsThreadPrivateSet(pyDevReasonID, NULL);
|
epicsThreadPrivateSet(pyDevReasonID, NULL);
|
||||||
|
|
||||||
|
Py_DECREF(self);
|
||||||
|
|
||||||
if(!pact) {
|
if(!pact) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Python Device record was not active");
|
PyErr_SetString(PyExc_ValueError, "Python Device record was not active");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(self);
|
|
||||||
|
|
||||||
return PyLong_FromLong(ret);
|
return PyLong_FromLong(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user