]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
kcc/graph: add __hash__ to InternalEdge for py3
authorJoe Guo <joeg@catalyst.net.nz>
Tue, 10 Apr 2018 03:06:51 +0000 (15:06 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 13 Apr 2018 05:27:13 +0000 (07:27 +0200)
In py3, if a class defines `__eq__()` but not `__hash__()`, its instances will
not be usable as items in hashable collections, e.g.: set.

Add `__hash__()` to InternalEdge, so it can be added to a set in py3.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/kcc/graph.py

index a0bff6997db32c4fe72a9d49ec86f4d480450627..fb3ca0c81c2a447ca80e8d77d758a23f8da37336 100644 (file)
@@ -805,6 +805,11 @@ class InternalEdge(object):
         self.e_type = eType
         self.site_link = site_link
 
+    def __hash__(self):
+        return hash((
+            self.v1, self.v2, self.red_red, self.repl_info, self.e_type,
+            self.site_link))
+
     def __eq__(self, other):
         return not self < other and not other < self