From 53b95b865f7aabfa36ebac5514d604028346d001 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 29 May 2020 14:31:55 -0700 Subject: [PATCH] __eq__ should be redefined if __hash__ is defined. --- lib/ansible/module_utils/common/collections.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ansible/module_utils/common/collections.py b/lib/ansible/module_utils/common/collections.py index 0a166cd4cf7..78f8bf3a296 100644 --- a/lib/ansible/module_utils/common/collections.py +++ b/lib/ansible/module_utils/common/collections.py @@ -28,6 +28,15 @@ class ImmutableDict(Hashable, Mapping): def __hash__(self): return hash(frozenset(self.items())) + def __eq__(self, other): + try: + if self.__hash__() == hash(other): + return True + except TypeError: + pass + + return False + def __repr__(self): return 'ImmutableDict({0})'.format(repr(self._store))