fix handleDbResult so that it will return an empty list when nothing matches instead...
authorgafton <devnull@localhost>
Fri, 29 Dec 2000 19:25:38 +0000 (19:25 +0000)
committergafton <devnull@localhost>
Fri, 29 Dec 2000 19:25:38 +0000 (19:25 +0000)
CVS patchset: 4382
CVS date: 2000/12/29 19:25:38

python/ChangeLog [new file with mode: 0644]
python/rpmmodule.c

diff --git a/python/ChangeLog b/python/ChangeLog
new file mode 100644 (file)
index 0000000..906a3a5
--- /dev/null
@@ -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
+
index c11a910..04558a8 100644 (file)
@@ -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;
 }