summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorgafton <devnull@localhost>2000-12-29 19:25:38 +0000
committergafton <devnull@localhost>2000-12-29 19:25:38 +0000
commitaff441656cc10f1326a3d65c96051f8096880de1 (patch)
tree03412f062743e73e4180d38634607c4c6a896345 /python
parentbc5ea0ac35691a2400767c661fd204e54d614c3e (diff)
downloadlibrpm-tizen-aff441656cc10f1326a3d65c96051f8096880de1.tar.gz
librpm-tizen-aff441656cc10f1326a3d65c96051f8096880de1.tar.bz2
librpm-tizen-aff441656cc10f1326a3d65c96051f8096880de1.zip
fix handleDbResult so that it will return an empty list when nothing matches instead of delivering an exception
CVS patchset: 4382 CVS date: 2000/12/29 19:25:38
Diffstat (limited to 'python')
-rw-r--r--python/ChangeLog5
-rw-r--r--python/rpmmodule.c15
2 files changed, 11 insertions, 9 deletions
diff --git a/python/ChangeLog b/python/ChangeLog
new file mode 100644
index 000000000..906a3a56a
--- /dev/null
+++ b/python/ChangeLog
@@ -0,0 +1,5 @@
+2000-12-29 Cristian Gafton <gafton@redhat.com>
+
+ * rpmmodule.c(handleDbResult): don't freak out when nothing matches;
+ return empty list
+
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index c11a91075..04558a834 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -890,19 +890,16 @@ static PyObject * rpmdbNext(rpmdbObject * s, PyObject * args) {
static PyObject * handleDbResult(rpmdbMatchIterator mi) {
PyObject * list, *o;
- if (mi == NULL) {
- PyErr_SetString(pyrpmError, "error reading from database");
- return NULL;
- }
-
list = PyList_New(0);
/* XXX FIXME: unnecessary header mallocs are side effect here */
- while (rpmdbNextIterator(mi)) {
- PyList_Append(list, o=PyInt_FromLong(rpmdbGetIteratorOffset(mi)));
- Py_DECREF(o);
+ if (mi != NULL) {
+ while (rpmdbNextIterator(mi)) {
+ PyList_Append(list, o=PyInt_FromLong(rpmdbGetIteratorOffset(mi)));
+ Py_DECREF(o);
+ }
+ rpmdbFreeIterator(mi);
}
- rpmdbFreeIterator(mi);
return list;
}