diff options
author | Florian Festi <ffesti@redhat.com> | 2010-10-21 11:59:14 +0200 |
---|---|---|
committer | Florian Festi <ffesti@redhat.com> | 2010-10-21 11:59:14 +0200 |
commit | 5e007f2258b845cfbe0a66bc8bf09eb9bdc2c9bc (patch) | |
tree | b2431fff2666dc789c53d4751edb4db69f9a848e /python | |
parent | f1883045409930f186fd540f7df9688a4b5811b4 (diff) | |
download | librpm-tizen-5e007f2258b845cfbe0a66bc8bf09eb9bdc2c9bc.tar.gz librpm-tizen-5e007f2258b845cfbe0a66bc8bf09eb9bdc2c9bc.tar.bz2 librpm-tizen-5e007f2258b845cfbe0a66bc8bf09eb9bdc2c9bc.zip |
Fix Python bindings and raise KeyError when there is no index for the given tag
Diffstat (limited to 'python')
-rw-r--r-- | python/rpmts-py.c | 9 |
1 files changed, 7 insertions, 2 deletions
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; |