summaryrefslogtreecommitdiff
path: root/src/zope/interface/interface.py
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2011-05-26 16:10:57 +0000
committerTres Seaver <tseaver@palladion.com>2011-05-26 16:10:57 +0000
commitc7a10ce52ad99fb6528416678fc057e5338d3e2b (patch)
tree5148fd7f4e31d3a90e28fc461a89fb566a4dd4a2 /src/zope/interface/interface.py
parentd72033b032d849125f8fddd2475489ae9a39e281 (diff)
downloadzope-interface-c7a10ce52ad99fb6528416678fc057e5338d3e2b.tar.gz
Correct comparison of interfaces from different modules but with the same name.
Fixes LP #570942.
Diffstat (limited to 'src/zope/interface/interface.py')
-rw-r--r--src/zope/interface/interface.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/zope/interface/interface.py b/src/zope/interface/interface.py
index a2bd3ae..ed6366d 100644
--- a/src/zope/interface/interface.py
+++ b/src/zope/interface/interface.py
@@ -670,31 +670,41 @@ class InterfaceClass(Element, InterfaceBase, Specification):
sort before None.
"""
- if o1 == o2:
- return 0
-
if o1 is None:
return 1
if o2 is None:
return -1
- n1 = (getattr(o1, '__name__', ''),
- getattr(getattr(o1, '__module__', None), '__name__', ''))
- n2 = (getattr(o2, '__name__', ''),
- getattr(getattr(o2, '__module__', None), '__name__', ''))
+ n1 = (getattr(o1, '__name__', ''), getattr(o1, '__module__', ''))
+ n2 = (getattr(o2, '__name__', ''), getattr(o2, '__module__', ''))
+ # This spelling works under Python3, which doesn't have cmp().
return (n1 > n2) - (n1 < n2)
+ def __eq__(self, other):
+ c = self.__cmp(self, other)
+ return c == 0
+
+ def __ne__(self, other):
+ c = self.__cmp(self, other)
+ return c != 0
+
def __lt__(self, other):
c = self.__cmp(self, other)
- #print '<', self, other, c < 0, c
return c < 0
+ def __le__(self, other):
+ c = self.__cmp(self, other)
+ return c <= 0
+
def __gt__(self, other):
c = self.__cmp(self, other)
- #print '>', self, other, c > 0, c
return c > 0
+ def __ge__(self, other):
+ c = self.__cmp(self, other)
+ return c >= 0
+
Interface = InterfaceClass("Interface", __module__ = 'zope.interface')