diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-10-09 11:44:41 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-10-09 11:44:41 +0300 |
commit | 4e5132e443a9f062bfad83f531b43a9d5d6df1da (patch) | |
tree | 59879e03572a77b12ede0dba5679b3d0019df497 | |
parent | cbad134dd453a24d3e0e55ad81dff0e0baa2f7e9 (diff) | |
download | rpm-4e5132e443a9f062bfad83f531b43a9d5d6df1da.tar.gz rpm-4e5132e443a9f062bfad83f531b43a9d5d6df1da.tar.bz2 rpm-4e5132e443a9f062bfad83f531b43a9d5d6df1da.zip |
Handle NULL in ts get/setKeyring as python None
-rw-r--r-- | python/rpmts-py.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/python/rpmts-py.c b/python/rpmts-py.c index c1c9779c3..04dd78381 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -424,10 +424,12 @@ rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args, PyObject * kwds) static PyObject *rpmts_setKeyring(rpmtsObject *s, PyObject *arg) { rpmKeyring keyring = NULL; - if (!PyArg_Parse(arg, "O&", rpmKeyringFromPyObject, &keyring)) + if (arg == Py_None || rpmKeyringFromPyObject(arg, &keyring)) { + return PyBool_FromLong(rpmtsSetKeyring(s->ts, keyring) == 0); + } else { + PyErr_SetString(PyExc_TypeError, "rpm.keyring or None expected"); return NULL; - - return PyBool_FromLong(rpmtsSetKeyring(s->ts, keyring) == 0); + } } static PyObject *rpmts_getKeyring(rpmtsObject *s, PyObject *args, PyObject *kwds) @@ -441,7 +443,11 @@ static PyObject *rpmts_getKeyring(rpmtsObject *s, PyObject *args, PyObject *kwds return NULL; keyring = rpmtsGetKeyring(s->ts, autoload); - return rpmKeyring_Wrap(&rpmKeyring_Type, keyring); + if (keyring) { + return rpmKeyring_Wrap(&rpmKeyring_Type, keyring); + } else { + Py_RETURN_NONE; + } } static void * |