From 18e8c3bc8aea1c1eefa888ab34832abce1898a9d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 13 Apr 2009 20:54:59 +0000 Subject: [PATCH] gdb * 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 | 5 +++++ gdb/python/python-frame.c | 20 +++++++++++--------- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.python/python-frame.exp | 2 ++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a300c7e1582..ef820181d3a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2009-04-13 Tom Tromey + + * python/python-frame.c (frapy_richcompare): Return + Py_NotImplemented, not an error. Handle Py_NE as well. + 2009-04-13 Eli Zaretskii * charset.c (EILSEQ): Define if not defined by system headers. diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c index 8d6127ee5da..a97009f8f84 100644 --- a/gdb/python/python-frame.c +++ b/gdb/python/python-frame.c @@ -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; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index dd8b2ebae96..252206f8894 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-13 Tom Tromey + + * gdb.python/python-frame.exp (gdb_py_test_silent_cmd): Test != + operator on Frame. + 2009-04-03 Ulrich Weigand * gdb.base/attach.exp: Re-enable for spu*-*-* targets. diff --git a/gdb/testsuite/gdb.python/python-frame.exp b/gdb/testsuite/gdb.python/python-frame.exp index b1ee9be408f..82b526ec765 100644 --- a/gdb/testsuite/gdb.python/python-frame.exp +++ b/gdb/testsuite/gdb.python/python-frame.exp @@ -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" -- 2.30.2