This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/3] gdb-gdb.py.in: Fix ordering of TypeFlags objects with Python 3
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: <gdb-patches at sourceware dot org>
- Cc: Simon Marchi <simon dot marchi at ericsson dot com>
- Date: Fri, 15 Jun 2018 17:27:20 -0400
- Subject: [PATCH 2/3] gdb-gdb.py.in: Fix ordering of TypeFlags objects with Python 3
- References: <1529098041-2212-1-git-send-email-simon.marchi@ericsson.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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/gdb-gdb.py.in | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in
index b8bb1ad..c844e4c 100644
--- a/gdb/gdb-gdb.py.in
+++ b/gdb/gdb-gdb.py.in
@@ -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.
--
2.7.4