Don't allow unversioned migrationitems to be hashed

Unversioned migration items match different versioned items for the same
source, so hashing them will not produce a correct result.

Closes: #945471
This commit is contained in:
Ivo De Decker 2020-01-16 16:21:22 +00:00
parent 18f71a01f5
commit 62c309da07
2 changed files with 6 additions and 1 deletions

View File

@ -83,7 +83,8 @@ class Hint(object):
if self.type != other.type:
return False
else:
return frozenset(self.packages) == frozenset(other.packages)
# we can't use sets, because unversioned items cannot be hashed
return sorted(self.packages) == sorted(other.packages)
@property
def type(self):

View File

@ -76,6 +76,10 @@ class MigrationItem(object):
return isequal
def __hash__(self):
if not self.version:
raise AssertionError("trying to hash unversioned MigrationItem: %s" %
(self.name))
return hash((self.uvname, self.version))
def __lt__(self, other):