Author: fw
Date: 2005-09-19 15:12:37 +0000 (Mon, 19 Sep 2005)
New Revision: 2045
Modified:
lib/python/debian_support.py
Log:
Fix bug in the version comparison algorithm.
lib/python/debian_support.py (letterValue):
New global variable.
(Version.__parse_1):
Use it to sort letters before non-letters.
(test):
New test case.
Modified: lib/python/debian_support.py
==================================================================---
lib/python/debian_support.py 2005-09-19 11:22:21 UTC (rev 2044)
+++ lib/python/debian_support.py 2005-09-19 15:12:37 UTC (rev 2045)
@@ -52,6 +52,21 @@
file.write("%s:%d: %s\n" % (self.filename, self.lineno,
self.msg))
file.flush()
+letterValue = [None] * 256
+def initLetterValue():
+ c = 0
+ for x in range(ord(''A''), ord(''Z'') + 1):
+ letterValue[x] = chr(c)
+ c += 1
+ for x in range(ord(''a''), ord(''z'') + 1):
+ letterValue[x] = chr(c)
+ c += 1
+ for x in "+-.:":
+ letterValue[ord(x)] = chr(c)
+ c += 1
+initLetterValue()
+del initLetterValue
+
class Version:
"""This class implements Debian version
numbers."""
@@ -93,6 +108,10 @@
while x is not None and x <> '''':
(nd, x) = non_digits.match(x).groups()
(d, x) = digits.match(x).groups()
+ nd_l = []
+ for ch in nd:
+ nd_l.append(letterValue[ord(ch)])
+ nd = ''''.join(nd_l)
if d == '''':
d = 0
else:
@@ -414,6 +433,7 @@
assert Version(''0.9.2-5'') <
Version(''0.9.2+cvs.1.0.dev.2004.07.28-1.5'')
assert Version(''1:500'') <
Version(''1:5000'')
assert Version(''100:500'') >
Version(''11:5000'')
+ assert Version(''1.0.4-2'') >
Version(''1.0pre7-2'')
# Release
assert internRelease(''sarge'') <
internRelease(''etch'')