Fix int overflow exception in unittest

Fixes:

  File ".../versioning/version.py", line 30, in __init__
      if self < 0:
  OverflowError: Python int too large to convert to C long

Don't use __cmp__ which is deprecated and restricted to C
long ints, rather than python's arbitrary precision ints.

Copied from Pádraig Brady's Fedora patch:

http://pkgs.fedoraproject.org/cgit/python-migrate.git/commit/?id=a01bf449

Co-authored-by: Pádraig Brady <pbrady@redhat.com>
Change-Id: I71f349f97507525b2f2edaf034005d67b6cc3987
This commit is contained in:
Matt Riedemann 2013-11-05 18:43:08 -08:00
parent 2485118c24
commit c49b8beb83

View File

@ -37,8 +37,23 @@ class VerNum(object):
def __sub__(self, value):
return self + (int(value) * -1)
def __cmp__(self, value):
return int(self) - int(value)
def __eq__(self, value):
return int(self) == int(value)
def __ne__(self, value):
return int(self) != int(value)
def __lt__(self, value):
return int(self) < int(value)
def __gt__(self, value):
return int(self) > int(value)
def __ge__(self, value):
return int(self) >= int(value)
def __le__(self, value):
return int(self) <= int(value)
def __repr__(self):
return "<VerNum(%s)>" % self.value