[Rpm-maint] [PATCH] Auto convert hdr['epoch'] from None to 0

James Antill james at fedoraproject.org
Tue Nov 3 17:38:06 UTC 2009


From: James Antill <james at and.org>

---
 python/header-py.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/python/header-py.c b/python/header-py.c
index 9272fc8..5f09bab 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -456,7 +456,13 @@ static PyObject * hdrGetTag(Header h, rpmTag tag)
 
     /* rpmtd_AsPyObj() knows how to handle empty containers and all */
     (void) headerGet(h, tag, &td, HEADERGET_EXT);
-    res = rpmtd_AsPyobj(&td);
+    if ((tag == RPMTAG_EPOCH) && (rpmtdCount(&td) < 1)) {
+	res = PyLong_FromLongLong(0); /* noone likes epoch == None */
+    }
+    else {
+	res = rpmtd_AsPyobj(&td);
+    }
+
     rpmtdFreeData(&td);
     return res;
 }
-- 
1.6.2.5



More information about the Rpm-maint mailing list