public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 2/3] gdb-gdb.py.in: Fix ordering of TypeFlags objects with Python 3
Date: Fri, 15 Jun 2018 21:27:00 -0000	[thread overview]
Message-ID: <1529098041-2212-2-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1529098041-2212-1-git-send-email-simon.marchi@ericsson.com>

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

  reply	other threads:[~2018-06-15 21:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 21:27 [PATCH 1/3] Copy gdb-gdb.py to build dir Simon Marchi
2018-06-15 21:27 ` Simon Marchi [this message]
2018-06-15 21:28 ` [PATCH 3/3] gdb-gdb.py.in: Don't print value's tag_name Simon Marchi
2018-06-27 18:39 ` [PATCH 1/3] Copy gdb-gdb.py to build dir Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1529098041-2212-2-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).