mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Bugfix: if you define a custom __eq__, you must define a __hash__ too
Also, on Python 3 the stock object.__hash__ raises an error ("unhashable type"), and we have code that uses Host instances as dict keys.
This commit is contained in:
parent
a2bc6b4b26
commit
0624797375
2 changed files with 6 additions and 0 deletions
|
@ -41,6 +41,9 @@ class Host:
|
|||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.name)
|
||||
|
||||
def serialize(self):
|
||||
groups = []
|
||||
for group in self.groups:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue