diff options
-rw-r--r-- | pym/portage/tests/versions/test_vercmp.py | 6 | ||||
-rw-r--r-- | pym/portage/versions.py | 17 |
2 files changed, 15 insertions, 8 deletions
diff --git a/pym/portage/tests/versions/test_vercmp.py b/pym/portage/tests/versions/test_vercmp.py index 22ab2aa10..3aecbfa87 100644 --- a/pym/portage/tests/versions/test_vercmp.py +++ b/pym/portage/tests/versions/test_vercmp.py @@ -17,7 +17,8 @@ class VerCmpTestCase(TestCase): ("1.0-r1", "1.0"), ("999999999999999999999999999999", "999999999999999999999999999998"), ("1.0.0", "1.0"), - ("12.2.5", "12.2b"), + ("1.0b", "1.0.0"), + ("12.2b", "12.2.5"), ] for test in tests: self.failIf( vercmp( test[0], test[1] ) <= 0, msg="%s < %s? Wrong!" % (test[0],test[1]) ) @@ -35,7 +36,8 @@ class VerCmpTestCase(TestCase): ("1.0-r0", "1.0-r1"), ("1.0", "1.0-r1"), ("1.0", "1.0.0"), - ("12.2b", "12.2.5"), + ("1.0.0", "1.0b"), + ("12.2.5", "12.2b"), ] for test in tests: self.failIf( vercmp( test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0],test[1])) diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 426abff18..72c79ba77 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -103,6 +103,17 @@ def vercmp(ver1, ver2, silent=1): if len(match1.group(3)) or len(match2.group(3)): vlist1 = match1.group(3)[1:].split(".") vlist2 = match2.group(3)[1:].split(".") + + # and now the final letter + if match1.group(5): + vlist1.append(str(ord(match1.group(5)))) + else: + vlist1.append('0') + if match2.group(5): + vlist2.append(str(ord(match2.group(5)))) + else: + vlist2.append('0') + for i in range(0, max(len(vlist1), len(vlist2))): # Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it # would be ambiguous if two versions that aren't literally equal @@ -131,12 +142,6 @@ def vercmp(ver1, ver2, silent=1): list1.append(int(vlist1[i].ljust(max_len, "0"))) list2.append(int(vlist2[i].ljust(max_len, "0"))) - # and now the final letter - if len(match1.group(5)): - list1.append(ord(match1.group(5))) - if len(match2.group(5)): - list2.append(ord(match2.group(5))) - for i in range(0, max(len(list1), len(list2))): if len(list1) <= i: vercmp_cache[mykey] = -1 |