[Rpm-maint] [PATCH] Auto convert hdr['epoch'] from None to 0
Panu Matilainen
pmatilai at redhat.com
Fri Nov 20 08:07:17 UTC 2009
On Tue, 3 Nov 2009, James Antill wrote:
> 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;
> }
NAK. Sure for rpm internals no epoch is the same as epoch 0, but it's not
the same for all uses: you might not want to show the million useless zero
epochs to users, and the above would make it impossible to determine which
packages actually *have* set an epoch (if only for distro statistics
collection or whatever).
That said, I've no problem with adding a tag extension which returns the
epoch in numeric format always (ie 0 for no epoch), call it
RPMTAG_EPOCHNUM or whatever. That wont break anything and lets the
user/caller decide which format is the best for a given situation.
- Panu -
More information about the Rpm-maint
mailing list