summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pym/portage/versions.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index d3f256dc..13ce4789 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -124,9 +124,12 @@ def vercmp(ver1, ver2, silent=1):
vercmp_cache[mykey] = 1
return 1
elif list1[i] != list2[i]:
- vercmp_cache[mykey] = list1[i] - list2[i]
- return list1[i] - list2[i]
-
+ a = list1[i]
+ b = list2[i]
+ rval = (a > b) - (a < b)
+ vercmp_cache[mykey] = rval
+ return rval
+
# main version is equal, so now compare the _suffix part
list1 = match1.group(6).split("_")[1:]
list2 = match2.group(6).split("_")[1:]
@@ -142,7 +145,11 @@ def vercmp(ver1, ver2, silent=1):
else:
s2 = suffix_regexp.match(list2[i]).groups()
if s1[0] != s2[0]:
- return suffix_value[s1[0]] - suffix_value[s2[0]]
+ a = suffix_value[s1[0]]
+ b = suffix_value[s2[0]]
+ rval = (a > b) - (a < b)
+ vercmp_cache[mykey] = rval
+ return rval
if s1[1] != s2[1]:
# it's possible that the s(1|2)[1] == ''
# in such a case, fudge it.
@@ -154,9 +161,11 @@ def vercmp(ver1, ver2, silent=1):
r2 = int(s2[1])
except ValueError:
r2 = 0
- if r1 - r2:
- return r1 - r2
-
+ rval = (r1 > r2) - (r1 < r2)
+ if rval:
+ vercmp_cache[mykey] = rval
+ return rval
+
# the suffix part is equal to, so finally check the revision
if match1.group(10):
r1 = int(match1.group(10))
@@ -166,8 +175,9 @@ def vercmp(ver1, ver2, silent=1):
r2 = int(match2.group(10))
else:
r2 = 0
- vercmp_cache[mykey] = r1 - r2
- return r1 - r2
+ rval = (r1 > r2) - (r1 < r2)
+ vercmp_cache[mykey] = rval
+ return rval
def pkgcmp(pkg1, pkg2):
"""