Commit a340c26a authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

charachers avec [~-+] in version can be more than ascii

parent 8f8ecb2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -6,7 +6,7 @@ __________________________
A valid version is an integer without dot.
A valid version is an integer without dot.
A version n, may be followed by a ~, to indicate it's inferior to n
A version n, may be followed by a ~, to indicate it's inferior to n
A version n, may be followed by a +, to indicate it's superior to n
A version n, may be followed by a +, to indicate it's superior to n
Any following ascii chars after ~ or + are ignored
Any following chars after ~ or + are ignored


Examples:
Examples:
  1 < 2
  1 < 2
+3 −3
Original line number Original line Diff line number Diff line
@@ -478,9 +478,9 @@ def compare_versions(v1, v2):
        if type(version) is int or type(version) is float:
        if type(version) is int or type(version) is float:
            return float(version)
            return float(version)
        elif isinstance(version, basestring):
        elif isinstance(version, basestring):
            iv = re.match("^(\d+)(?:([-~+])\w*)?$", version)
            iv = re.match("^(\d+)(?:([-~+]).*)?$", version)
            if iv is None:
            if iv is None:
                raise TypeError('Invalid version: %s' % version)
                raise TypeError('Invalid version format: %s' % version)
            rv = float(iv.group(1))
            rv = float(iv.group(1))
            if iv.group(2) == "~":
            if iv.group(2) == "~":
                rv -= 0.1
                rv -= 0.1
@@ -488,7 +488,7 @@ def compare_versions(v1, v2):
                rv += 0.1
                rv += 0.1
            return rv
            return rv
        else:
        else:
            raise TypeError('Invalid version: %s' % version)
            raise TypeError('Invalid version format: %s' % version)


    fv1 = get_ver(v1)
    fv1 = get_ver(v1)
    fv2 = get_ver(v2)
    fv2 = get_ver(v2)