From 62c309da074f24328bf55298288fc2569ac1d7fd Mon Sep 17 00:00:00 2001 From: Ivo De Decker Date: Thu, 16 Jan 2020 16:21:22 +0000 Subject: [PATCH] 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 --- britney2/hints.py | 3 ++- britney2/migrationitem.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/britney2/hints.py b/britney2/hints.py index 47cc0ff..ed0113a 100644 --- a/britney2/hints.py +++ b/britney2/hints.py @@ -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): diff --git a/britney2/migrationitem.py b/britney2/migrationitem.py index 01ee6c1..7e0065e 100644 --- a/britney2/migrationitem.py +++ b/britney2/migrationitem.py @@ -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):