This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[python] fix frame comparison function


This fixes the frame comparison function.

It also changes FrameIterator.py, though that is not strictly needed.

I will push this upstream as well.

Tom

b/gdb/ChangeLog:
2009-04-13  Tom Tromey  <tromey@redhat.com>

	* python/python-frame.c (frapy_richcompare): Return
	Py_NotImplemented, not an error.  Handle Py_NE as well.
	* python/lib/gdb/FrameIterator.py (FrameIterator.next): Use 'is'.

diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
index 87fb074..5654546 100644
--- a/gdb/python/lib/gdb/FrameIterator.py
+++ b/gdb/python/lib/gdb/FrameIterator.py
@@ -1,6 +1,6 @@
 # Iterator over frames.
 
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ class FrameIterator:
 
     def next (self):
         result = self.frame
-        if result == None:
+        if result is None:
             raise StopIteration
         self.frame = result.older ()
         return result
diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c
index 6c33e65..53f29d4 100644
--- a/gdb/python/python-frame.c
+++ b/gdb/python/python-frame.c
@@ -563,21 +563,23 @@ gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
 static PyObject *
 frapy_richcompare (PyObject *self, PyObject *other, int op)
 {
-  if (!PyObject_TypeCheck (other, &frame_object_type))
-    {
-      PyErr_SetString (PyExc_TypeError, "Frame object expected in comparison.");
-      return NULL;
-    }
-  else if (op != Py_EQ)
+  int result;
+
+  if (!PyObject_TypeCheck (other, &frame_object_type)
+      || (op != Py_EQ && op != Py_NE))
     {
-      PyErr_SetString (PyExc_TypeError, "Invalid comparison for gdb.Frame.");
-      return NULL;
+      Py_INCREF (Py_NotImplemented);
+      return Py_NotImplemented;
     }
 
   if (frame_id_eq (((frame_object *) self)->frame_id,
 		   ((frame_object *) other)->frame_id))
-    Py_RETURN_TRUE;
+    result = Py_EQ;
+  else
+    result = Py_NE;
 
+  if (op == result)
+    Py_RETURN_TRUE;
   Py_RETURN_FALSE;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]