summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-05-19 10:12:43 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-06-11 10:29:17 +0300
commit6b38fba9bc6ea85e36bb2140cce1a895cfa28537 (patch)
tree40f98678e5e012751964f2c1d02f3af06e168e75
parent0757c1cf5e3e76399e7bf05bc1efcb21c676406c (diff)
downloadrpm-6b38fba9bc6ea85e36bb2140cce1a895cfa28537.tar.gz
Handle non-existent dependency sets in python (RhBug:593553)
- rpmdsNew() returns NULL if the requested dependency type doesn't exist in the header. The C-side API can handle NULL to all rpmds "methods" and this is how librpm deals with non-existent sets rather than waste memory on for empty ds structures. However the python side wasn't expecting NULL for legal requests (but not setting error either) and thus blowing up with SystemError exception. - Raise TypeError on illegal arguments to rpm.ds constructor, and present non-existent dependency sets as empty rpm.ds objects to python. This lets python callers use iteration over ds items regardless of whether the dependency actually exists or not. The alternative of returning None (or raising exceptions) would break existing code for no particularly good reason. (cherry picked from commit 0e0e332b466a9784620c483faa374067381e96ce)
-rw-r--r--python/rpmds-py.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/python/rpmds-py.c b/python/rpmds-py.c
index 49a02e483..c82ad7add 100644
--- a/python/rpmds-py.c
+++ b/python/rpmds-py.c
@@ -302,10 +302,11 @@ static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kw
} else {
ds = rpmdsNew(h, tagN, 0);
}
+ } else {
+ PyErr_SetString(PyExc_TypeError, "header or tuple expected");
+ return NULL;
}
- if (ds == NULL) return NULL;
-
return rpmds_Wrap(subtype, ds);
}