gdb
authorTom Tromey <tromey@redhat.com>
Mon, 13 Apr 2009 20:54:59 +0000 (20:54 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 13 Apr 2009 20:54:59 +0000 (20:54 +0000)
* python/python-frame.c (frapy_richcompare): Return
Py_NotImplemented, not an error.  Handle Py_NE as well.
gdb/testsuite
* gdb.python/python-frame.exp (gdb_py_test_silent_cmd): Test !=
operator on Frame.

gdb/ChangeLog
gdb/python/python-frame.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/python-frame.exp

index a300c7e1582ceae023cb20d55724ac21424483ac..ef820181d3ab954bfd2feb2e63b0f73513792d70 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2009-04-13  Eli Zaretskii  <eliz@gnu.org>
 
        * charset.c (EILSEQ): Define if not defined by system headers.
index 8d6127ee5da209b4d3030821d78c5a1b3cb9ee5f..a97009f8f8428301e952129bb266041a1c31a6f6 100644 (file)
@@ -415,21 +415,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 dd8b2ebae96afdb0fa73e6a3d0b1273f03b05b2a..252206f88946f884045a9cbccb4d78f255a35b1a 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-13  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.python/python-frame.exp (gdb_py_test_silent_cmd): Test !=
+       operator on Frame.
+
 2009-04-03  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * gdb.base/attach.exp: Re-enable for spu*-*-* targets.
index b1ee9be408f9456c5c379b4cd978e91d1e36a2c6..82b526ec76595c2b63e3bfd1b7962c6815e59178 100644 (file)
@@ -70,6 +70,8 @@ gdb_py_test_silent_cmd "python f0 = f1.newer ()" "get first frame" 0
 
 gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)"
 gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)"
+gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)"
+gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)"
 gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid"
 gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name"
 gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type"
This page took 0.04095 seconds and 4 git commands to generate.