Fix comparison to arbitrary objects
diff --git a/Lib/fontTools/ttLib/tables/DefaultTable.py b/Lib/fontTools/ttLib/tables/DefaultTable.py
index e960ff3..ff45bc3 100644
--- a/Lib/fontTools/ttLib/tables/DefaultTable.py
+++ b/Lib/fontTools/ttLib/tables/DefaultTable.py
@@ -37,5 +37,9 @@
 		return "<'%s' table at %x>" % (self.tableTag, id(self))
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.__dict__, other.__dict__)
 
diff --git a/Lib/fontTools/ttLib/tables/M_E_T_A_.py b/Lib/fontTools/ttLib/tables/M_E_T_A_.py
index 78d5987..327b28a 100644
--- a/Lib/fontTools/ttLib/tables/M_E_T_A_.py
+++ b/Lib/fontTools/ttLib/tables/M_E_T_A_.py
@@ -236,6 +236,11 @@
 	def __cmp__(self, other):
 		"""Compare method, so a list of NameRecords can be sorted
 		according to the spec by just sorting it..."""
+
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.glyphID, other.glyphID)
 	
 	def __repr__(self):
@@ -321,6 +326,11 @@
 	def __cmp__(self, other):
 		"""Compare method, so a list of NameRecords can be sorted
 		according to the spec by just sorting it..."""
+
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.labelID, other.labelID)
 	
 	def __repr__(self):
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index d331a62..7574431 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -151,6 +151,10 @@
 			writer.newline()
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		# implemented so that list.sort() sorts according to the cmap spec.
 		selfTuple = (
 					self.platformID,
diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index 8332882..76d28fc 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -606,6 +606,10 @@
 			return GlyphCoordinates(), [], array.array("B")
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.__dict__, other.__dict__)
 
 
@@ -766,6 +770,10 @@
 		self.flags = safeEval(attrs["flags"])
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.__dict__, other.__dict__)
 
 class GlyphCoordinates:
diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
index 6dfa894..ed096c5 100644
--- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py
+++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
@@ -90,6 +90,10 @@
 		setattr(self, name, value)
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		selfdict = self.__dict__.copy()
 		otherdict = other.__dict__.copy()
 		# for testing purposes, compare without the modified and checkSumAdjustment
diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n.py b/Lib/fontTools/ttLib/tables/_k_e_r_n.py
index 4baece4..005d1ed 100644
--- a/Lib/fontTools/ttLib/tables/_k_e_r_n.py
+++ b/Lib/fontTools/ttLib/tables/_k_e_r_n.py
@@ -164,6 +164,10 @@
 		del self.kernTable[pair]
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.__dict__, other.__dict__)
 
 
diff --git a/Lib/fontTools/ttLib/tables/_l_o_c_a.py b/Lib/fontTools/ttLib/tables/_l_o_c_a.py
index feb8150..761ab9b 100644
--- a/Lib/fontTools/ttLib/tables/_l_o_c_a.py
+++ b/Lib/fontTools/ttLib/tables/_l_o_c_a.py
@@ -55,5 +55,9 @@
 		return len(self.locations)
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.locations, other.locations)
 
diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
index a4243fa..7a49171 100644
--- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py
+++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
@@ -88,6 +88,10 @@
 		return None # not found
 	
 	def __cmp__(self, other):
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		return cmp(self.names, other.names)
 	
 
@@ -133,6 +137,11 @@
 	def __cmp__(self, other):
 		"""Compare method, so a list of NameRecords can be sorted
 		according to the spec by just sorting it..."""
+
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
 		selftuple = (self.platformID,
 				self.platEncID,
 				self.langID,
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index f176856..0f6a4e8 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -288,10 +288,11 @@
 		return hash(self.items)
 	
 	def __cmp__(self, other):
-		if hasattr(other, "items"):
-			return cmp(self.items, other.items)
-		else:
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
 			return cmp(id(self), id(other))
+
+		return cmp(self.items, other.items)
 	
 	def _doneWriting(self, internedTables=None):
 		# Convert CountData references to data string items
@@ -670,14 +671,11 @@
 			setattr(self, conv.name, value)
 	
 	def __cmp__(self, other):
-		# this is only for debugging, so it's ok to barf
-		# when 'other' has no __dict__ or __class__
-		rv = cmp(self.__class__, other.__class__)
-		if not rv:
-			rv = cmp(self.__dict__, other.__dict__)
-			return rv
-		else:
-			return rv
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
+
+		return cmp(self.__dict__, other.__dict__)
 
 
 class FormatSwitchingBaseTable(BaseTable):
@@ -837,12 +835,8 @@
 			setattr(self, name, value)
 	
 	def __cmp__(self, other):
-		# this is only for debugging, so it's ok to barf
-		# when 'other' has no __dict__ or __class__
-		rv = cmp(self.__class__, other.__class__)
-		if not rv:
-			rv = cmp(self.__dict__, other.__dict__)
-			return rv
-		else:
-			return rv
+		if type(self) != type(other) or \
+		   self.__class__ != other.__class__:
+			return cmp(id(self), id(other))
 
+		return cmp(self.__dict__, other.__dict__)