From: Joe Guo Date: Tue, 10 Apr 2018 03:06:51 +0000 (+1200) Subject: kcc/graph: add __hash__ to InternalEdge for py3 X-Git-Tag: ldb-1.4.0~583 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6eb3391cc251cac484ce34397c18373331ffcb78;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- 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