summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/rpm/transaction.py10
-rw-r--r--python/rpmts-py.c33
2 files changed, 16 insertions, 27 deletions
diff --git a/python/rpm/transaction.py b/python/rpm/transaction.py
index c852b86b2..07a8db0fb 100644
--- a/python/rpm/transaction.py
+++ b/python/rpm/transaction.py
@@ -138,3 +138,13 @@ class TransactionSet(_rpm.ts):
res.append(((n, v, r),(needname,needver),needflags,sense,p.key))
return res
+
+ def hdrCheck(self, blob):
+ res, msg = _rpm.ts.hdrCheck(self, blob)
+ # generate backwards compatibly broken exceptions
+ if res == _rpm.RPMRC_NOKEY:
+ raise _rpm.error, "public key not availaiable"
+ elif res == _rpm.RPMRC_NOTTRUSTED:
+ raise _rpm.error, "public key not trusted"
+ elif res != _rpm.RPMRC_OK:
+ raise _rpm.error, msg
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 5d6bf8f4a..208de9a34 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -374,46 +374,25 @@ rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args, PyObject * kwds)
}
static PyObject *
-rpmts_HdrCheck(rpmtsObject * s, PyObject * args, PyObject * kwds)
+rpmts_HdrCheck(rpmtsObject * s, PyObject *obj)
{
PyObject * blob;
- PyObject * result = NULL;
char * msg = NULL;
const void * uh;
int uc;
rpmRC rpmrc;
- char * kwlist[] = {"headers", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:HdrCheck", kwlist, &blob))
+ if (!PyArg_Parse(obj, "S:HdrCheck", &blob))
return NULL;
uh = PyString_AsString(blob);
uc = PyString_Size(blob);
+ Py_BEGIN_ALLOW_THREADS;
rpmrc = headerCheck(s->ts, uh, uc, &msg);
+ Py_END_ALLOW_THREADS;
- switch (rpmrc) {
- case RPMRC_OK:
- Py_INCREF(Py_None);
- result = Py_None;
- break;
-
- case RPMRC_NOKEY:
- PyErr_SetString(pyrpmError, "public key not availaiable");
- break;
-
- case RPMRC_NOTTRUSTED:
- PyErr_SetString(pyrpmError, "public key not trusted");
- break;
-
- case RPMRC_FAIL:
- default:
- PyErr_SetString(pyrpmError, msg);
- break;
- }
- msg = _free(msg);
-
- return result;
+ return Py_BuildValue("(is)", rpmrc, msg);
}
static PyObject *
@@ -663,7 +642,7 @@ static struct PyMethodDef rpmts_methods[] = {
{"hdrFromFdno",(PyCFunction) rpmts_HdrFromFdno,METH_VARARGS|METH_KEYWORDS,
"ts.hdrFromFdno(fdno) -> hdr\n\
- Read a package header from a file descriptor.\n" },
- {"hdrCheck", (PyCFunction) rpmts_HdrCheck, METH_VARARGS|METH_KEYWORDS,
+ {"hdrCheck", (PyCFunction) rpmts_HdrCheck, METH_O,
NULL },
{"pgpPrtPkts", (PyCFunction) rpmts_PgpPrtPkts, METH_VARARGS|METH_KEYWORDS,
NULL },