summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-11-18 17:03:32 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-11-18 17:03:32 +0200
commit8f056c7849944abdf2e5ee86e8668bc6c61834ca (patch)
tree2727a31095f14aca5fc10935c14810a71154a82e /python
parent698c141fe3bfbc520a825e993a01a082cf80f69b (diff)
downloadlibrpm-tizen-8f056c7849944abdf2e5ee86e8668bc6c61834ca.tar.gz
librpm-tizen-8f056c7849944abdf2e5ee86e8668bc6c61834ca.tar.bz2
librpm-tizen-8f056c7849944abdf2e5ee86e8668bc6c61834ca.zip
Put a bit of sanity into python spec methods
- prep, build etc missing from spec are not errors - instead of returning NULLs (with no exception set!), just return None for anything that doesn't exist - dont bother with NULL checks, if s->spec is NULL then something else has screwed up big time
Diffstat (limited to 'python')
-rw-r--r--python/spec-py.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/python/spec-py.c b/python/spec-py.c
index d2c0b301b..ddb9739df 100644
--- a/python/spec-py.c
+++ b/python/spec-py.c
@@ -43,63 +43,54 @@ spec_dealloc(specObject * s)
Py_TYPE(s)->tp_free((PyObject *)s);
}
-/* XXX TODO return something sensible if spec exists but component (eg %clean)
- * does not. Possibly "" or None */
-
static PyObject *
spec_get_buildroot(specObject * s)
{
rpmSpec spec = specFromSpec(s);
- if (spec != NULL && spec->buildRoot) {
+ if (spec->buildRoot) {
return Py_BuildValue("s", spec->buildRoot);
}
- else {
- return NULL;
- }
+ Py_RETURN_NONE;
}
static PyObject *
spec_get_prep(specObject * s)
{
rpmSpec spec = specFromSpec(s);
- PyObject *res = NULL;
- if (spec != NULL && spec->prep) {
- res = Py_BuildValue("s",getStringBuf(spec->prep));
+ if (spec->prep) {
+ return Py_BuildValue("s",getStringBuf(spec->prep));
}
- return res;
+ Py_RETURN_NONE;
}
static PyObject *
spec_get_build(specObject * s)
{
rpmSpec spec = specFromSpec(s);
- PyObject *res = NULL;
- if (spec != NULL && spec->build) {
- res = Py_BuildValue("s",getStringBuf(spec->build));
+ if (spec->build) {
+ return Py_BuildValue("s",getStringBuf(spec->build));
}
- return res;
+ Py_RETURN_NONE;
}
static PyObject *
spec_get_install(specObject * s)
{
rpmSpec spec = specFromSpec(s);
- PyObject *res = NULL;
- if (spec != NULL && spec->install) {
- res = Py_BuildValue("s",getStringBuf(spec->install));
+ if (spec->install) {
+ return Py_BuildValue("s",getStringBuf(spec->install));
}
- return res;
+ Py_RETURN_NONE;
}
static PyObject *
spec_get_clean(specObject * s)
{
rpmSpec spec = specFromSpec(s);
- PyObject *res = NULL;
if (spec != NULL && spec->clean) {
- res = Py_BuildValue("s",getStringBuf(spec->clean));
+ return Py_BuildValue("s",getStringBuf(spec->clean));
}
- return res;
+ Py_RETURN_NONE;
}
static PyObject *