From 6fbde7f195be68b54c50801d2f2f71ea67d07efc Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 4 Jan 2010 19:58:13 +0000 Subject: Fix vercmp so 1b > 1 and add corresponding tests. svn path=/main/trunk/; revision=15162 --- pym/portage/versions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pym/portage/versions.py') diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 72c79ba77..208378172 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -100,10 +100,14 @@ def vercmp(ver1, ver2, silent=1): list2 = [int(match2.group(2))] # this part would greatly benefit from a fixed-length version pattern - if len(match1.group(3)) or len(match2.group(3)): + if match1.group(3) or match2.group(3): vlist1 = match1.group(3)[1:].split(".") vlist2 = match2.group(3)[1:].split(".") + else: + vlist1 = [] + vlist2 = [] + if match1.group(5) or match2.group(5): # and now the final letter if match1.group(5): vlist1.append(str(ord(match1.group(5)))) @@ -114,6 +118,8 @@ def vercmp(ver1, ver2, silent=1): else: vlist2.append('0') + if vlist1 or vlist2: + 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 -- cgit v1.2.3-1-g7c22