From 5e007f2258b845cfbe0a66bc8bf09eb9bdc2c9bc Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Thu, 21 Oct 2010 11:59:14 +0200 Subject: Fix Python bindings and raise KeyError when there is no index for the given tag --- python/rpmts-py.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 13bb3aa58..fb8f0c271 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -634,7 +634,7 @@ rpmts_Keys(rpmtsObject * s, PyObject * args, PyObject * kwds) { rpmTag tag; PyObject *mio = NULL; - char * kwlist[] = {"tag", "pattern", "type", NULL}; + char * kwlist[] = {"tag", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:Keys", kwlist, tagNumFromPyObject, &tag)) @@ -649,7 +649,12 @@ rpmts_Keys(rpmtsObject * s, PyObject * args, PyObject * kwds) } } - mio = rpmki_Wrap(&rpmki_Type, rpmdbKeyIteratorInit(rpmtsGetRdb(s->ts), tag), (PyObject*)s); + rpmdbKeyIterator ki = rpmdbKeyIteratorInit(rpmtsGetRdb(s->ts), tag); + if (ki == NULL) { + PyErr_SetString(PyExc_KeyError, "No index for this tag"); + return NULL; + } + mio = rpmki_Wrap(&rpmki_Type, ki, (PyObject*)s); exit: return mio; -- cgit v1.2.3