From 3df9dc71118b498694437f083bb174d774cc6337 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 28 Oct 2009 15:22:39 +0200 Subject: [PATCH] Eliminate the ambigious tp_compare from rpm.hdr - Avoids another Python 3 incompatibility as it doesn't have tp_compare anymore - We could add a compatible tp_richcompare, but comparisons like 'if h1 < h2: do foo' are highly ambiguous, callers are better of using explicit rpm.versinCompare(h1, h2) instead --- python/header-py.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/python/header-py.c b/python/header-py.c index 6f82dc7..9272fc8 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -311,11 +311,6 @@ static PyObject * hdr_dsOfHeader(PyObject * s) Py_BuildValue("(Oi)", s, RPMTAG_NEVR), NULL); } -static int hdr_compare(hdrObject * a, hdrObject * b) -{ - return rpmVersionCompare(a->h, b->h); -} - static long hdr_hash(PyObject * h) { return (long) h; @@ -527,7 +522,7 @@ PyTypeObject hdr_Type = { 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc) hdr_compare, /* tp_compare */ + 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -683,7 +678,7 @@ PyObject * versionCompare (PyObject * self, PyObject * args, PyObject * kwds) &h1, &hdr_Type, &h2)) return NULL; - return Py_BuildValue("i", hdr_compare(h1, h2)); + return Py_BuildValue("i", rpmVersionCompare(h1->h, h2->h)); } static int compare_values(const char *str1, const char *str2) -- 2.7.4