summaryrefslogtreecommitdiff
path: root/src/zope/interface/declarations.py
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2016-09-02 18:20:25 -0500
committerJason Madden <jamadden@gmail.com>2016-09-02 18:20:25 -0500
commitc0e980b4b986a95a7699d0f417d6f8ff185f48d7 (patch)
tree1e503365140693acc601b17b7d9f7435b1a1daa4 /src/zope/interface/declarations.py
parent69cacf26ff8f49a66b1396b8effe3f22e0e4d1a5 (diff)
downloadzope-interface-c0e980b4b986a95a7699d0f417d6f8ff185f48d7.tar.gz
Fix equality testing of implementedBy objects that have been proxied. Fixes #55.fix-55
Diffstat (limited to 'src/zope/interface/declarations.py')
-rw-r--r--src/zope/interface/declarations.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/zope/interface/declarations.py b/src/zope/interface/declarations.py
index d770fa0..48e459a 100644
--- a/src/zope/interface/declarations.py
+++ b/src/zope/interface/declarations.py
@@ -176,11 +176,12 @@ class Implements(Declaration):
def __hash__(self):
return Declaration.__hash__(self)
- def __eq__(self, other):
- return self is other
-
- def __ne__(self, other):
- return self is not other
+ # We want equality to be based on identity. However, we can't actually
+ # implement __eq__/__ne__ to do this because sometimes we get wrapped in a proxy.
+ # We need to let the proxy types implement these methods so they can handle unwrapping
+ # and then rely on: (1) the interpreter automatically changing `implements == proxy` into
+ # `proxy == implements` (which will call proxy.__eq__ to do the unwrapping) and then
+ # (2) the default equality semantics being identity based.
def __lt__(self, other):
c = self.__cmp(other)