summaryrefslogtreecommitdiff
path: root/python/samba/kcc
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2018-04-10 15:06:51 +1200
committerDouglas Bagnall <dbagnall@samba.org>2018-04-13 07:27:13 +0200
commit6eb3391cc251cac484ce34397c18373331ffcb78 (patch)
tree261b804874ed17c9614674de638f3550287abf16 /python/samba/kcc
parentc7f3c91b62c3f8f2bb44fc23bf65710e4b290105 (diff)
downloadsamba-6eb3391cc251cac484ce34397c18373331ffcb78.tar.gz
kcc/graph: add __hash__ to InternalEdge for py3
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>
Diffstat (limited to 'python/samba/kcc')
-rw-r--r--python/samba/kcc/graph.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/python/samba/kcc/graph.py b/python/samba/kcc/graph.py
index a0bff6997db..fb3ca0c81c2 100644
--- a/python/samba/kcc/graph.py
+++ b/python/samba/kcc/graph.py
@@ -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