Skip to content

Commit

Permalink
Fix version comparison bugs
Browse files Browse the repository at this point in the history
Example comparisons that work correctly now:
* 1.1k < 1.1k-12
* 1.1e < 1.1ek
  • Loading branch information
ra1nb0rn committed Feb 13, 2024
1 parent 9a4a07a commit 58e74c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpe_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def __lt__(self, other):
for i in range(iter_max):
if ord(part[i].lower()) > ord(other_part[i].lower()):
return False
if i == iter_max - 1 and ord(part[i].lower()) == ord(other_part[i].lower()):
if (i == iter_max - 1 and len(parts) == len(other_parts) and
len(part) == len(other_part) and
ord(part[i].lower()) == ord(other_part[i].lower())):
return False
else:
for i, char in enumerate(part):
Expand All @@ -132,7 +134,7 @@ def __lt__(self, other):

return True # if version part in front is smaller, the entire version is already smaller

if len(other_parts) > len(other_parts):
if len(parts) > len(other_parts):
return False

return True
Expand Down

0 comments on commit 58e74c3

Please sign in to comment.