1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

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>
This commit is contained in:
Joe Guo
2018-04-10 15:06:51 +12:00
committed by Douglas Bagnall
parent c7f3c91b62
commit 6eb3391cc2

View 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