gdb-gdb.py.in: Fix ordering of TypeFlags objects with Python 3
authorSimon Marchi <simon.marchi@ericsson.com>
Wed, 27 Jun 2018 18:32:05 +0000 (14:32 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 27 Jun 2018 18:32:05 +0000 (14:32 -0400)
Python 3 doesn't use __cmp__ to order objects, it uses __lt__.  Because
of this, we get this exception when trying to pretty-print "type"
objects:

I tested it with Python 2.7 as well.

gdb/ChangeLog:

* gdb-gdb.py.in (TypeFlag) <__cmp__>: Remove.
<__lt__>: Add.

gdb/ChangeLog
gdb/gdb-gdb.py.in

index 644aed8e7519e2ad70a82ba66c3eba40ad588f0a..9a740097c427f0c11c896e84075026b913dbb63f 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-27  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb-gdb.py.in (TypeFlag) <__cmp__>: Remove.
+       <__lt__>: Add.
+
 2018-06-27  Simon Marchi  <simon.marchi@ericsson.com>
 
        * gdb-gdb.py: Move to...
index b8bb1ada9e3e814326e247b70515defc9e638656..c844e4c98ac1ec0803a87a676ca582f64ed6c239 100644 (file)
@@ -38,9 +38,11 @@ class TypeFlag:
         self.name = name
         self.value = value
         self.short_name = name.replace("TYPE_INSTANCE_FLAG_", '')
-    def __cmp__(self, other):
+
+    def __lt__(self, other):
         """Sort by value order."""
-        return self.value.__cmp__(other.value)
+        return self.value < other.value
+        
 
 # A list of all existing TYPE_INSTANCE_FLAGS_* enumerations,
 # stored as TypeFlags objects.  Lazy-initialized.