py23 Remove uses of __cmp__ and cmp()
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index 80b9d80..d43f156 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -287,11 +287,10 @@
# only works after self._doneWriting() has been called
return hash(self.items)
- def __cmp__(self, other):
- if not isinstance(self, type(other)): return cmp(type(self), type(other))
- if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
-
- return cmp(self.items, other.items)
+ def __eq__(self, other):
+ if type(self) != type(other):
+ raise TypeError("unordered types %s() < %s()", type(self), type(other))
+ return self.items == other.items
def _doneWriting(self, internedTables=None):
# Convert CountData references to data string items
@@ -674,13 +673,14 @@
else:
setattr(self, conv.name, value)
- def __cmp__(self, other):
- if not isinstance(self, type(other)): return cmp(type(self), type(other))
- if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
+ def __eq__(self, other):
+ if type(self) != type(other):
+ raise TypeError("unordered types %s() < %s()", type(self), type(other))
self.ensureDecompiled()
+ other.ensureDecompiled()
- return cmp(self.__dict__, other.__dict__)
+ return self.__dict__ == other.__dict__
class FormatSwitchingBaseTable(BaseTable):
@@ -840,8 +840,7 @@
value.fromXML(name2, attrs2, content2, font)
setattr(self, name, value)
- def __cmp__(self, other):
- if not isinstance(self, type(other)): return cmp(type(self), type(other))
- if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
-
- return cmp(self.__dict__, other.__dict__)
+ def __eq__(self, other):
+ if type(self) != type(other):
+ raise TypeError("unordered types %s() < %s()", type(self), type(other))
+ return self.__dict__ == other.__dict__