mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
[gdb/python] Use py_{none,notimplemented} more often
Replace:
...
{
Py_INCREF (Py_NotImplemented);
return Py_NotImplemented;
}
...
with:
...
return py_notimplemented ().release ();
...
Likewise for py_none.
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
b9f58eb0d0
commit
5cb6772600
10 changed files with 13 additions and 42 deletions
|
|
@ -550,10 +550,7 @@ blpy_richcompare (PyObject *self, PyObject *other, int op)
|
|||
{
|
||||
if (!PyObject_TypeCheck (other, &block_object_type)
|
||||
|| (op != Py_EQ && op != Py_NE))
|
||||
{
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
return py_notimplemented ().release ();
|
||||
|
||||
bool expected = self == other;
|
||||
bool equal = op == Py_EQ;
|
||||
|
|
|
|||
|
|
@ -321,8 +321,7 @@ struct py_send_packet_callbacks : public send_remote_packet_callbacks
|
|||
else
|
||||
{
|
||||
/* We didn't get back any result data; set the result to None. */
|
||||
Py_INCREF (Py_None);
|
||||
m_result.reset (Py_None);
|
||||
m_result = py_none ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,10 +127,7 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
|
|||
gdbpy_print_stack ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Py_INCREF (Py_None);
|
||||
self_finishbp->return_value = Py_None;
|
||||
}
|
||||
self_finishbp->return_value = py_none ().release ();
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,8 +153,7 @@ frapy_name (PyObject *self, PyObject *args)
|
|||
}
|
||||
else
|
||||
{
|
||||
result = Py_None;
|
||||
Py_INCREF (Py_None);
|
||||
result = py_none ().release ();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -724,10 +723,7 @@ frapy_richcompare (PyObject *self, PyObject *other, int op)
|
|||
|
||||
if (!PyObject_TypeCheck (other, &frame_object_type)
|
||||
|| (op != Py_EQ && op != Py_NE))
|
||||
{
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
return py_notimplemented ().release ();
|
||||
|
||||
frame_object *self_frame = (frame_object *) self;
|
||||
frame_object *other_frame = (frame_object *) other;
|
||||
|
|
|
|||
|
|
@ -72,10 +72,7 @@ stpy_get_encoding (PyObject *self, void *closure)
|
|||
if (self_string->encoding)
|
||||
result = PyUnicode_FromString (self_string->encoding);
|
||||
else
|
||||
{
|
||||
result = Py_None;
|
||||
Py_INCREF (result);
|
||||
}
|
||||
result = py_none ().release ();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,10 +621,7 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
|
|||
const btpy_list_object * const obj2 = (btpy_list_object *) other;
|
||||
|
||||
if (Py_TYPE (self) != Py_TYPE (other))
|
||||
{
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
return py_notimplemented ().release ();
|
||||
|
||||
switch (op)
|
||||
{
|
||||
|
|
@ -652,8 +649,7 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
|
|||
break;
|
||||
}
|
||||
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
return py_notimplemented ().release ();
|
||||
}
|
||||
|
||||
/* Implementation of
|
||||
|
|
|
|||
|
|
@ -416,10 +416,7 @@ recpy_element_richcompare (PyObject *self, PyObject *other, int op)
|
|||
const recpy_element_object * const obj2 = (recpy_element_object *) other;
|
||||
|
||||
if (Py_TYPE (self) != Py_TYPE (other))
|
||||
{
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
return py_notimplemented ().release ();
|
||||
|
||||
switch (op)
|
||||
{
|
||||
|
|
@ -443,8 +440,7 @@ recpy_element_richcompare (PyObject *self, PyObject *other, int op)
|
|||
break;
|
||||
}
|
||||
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
return py_notimplemented ().release ();
|
||||
}
|
||||
|
||||
/* Create a new gdb.RecordGap object. */
|
||||
|
|
|
|||
|
|
@ -68,10 +68,7 @@ sympy_get_type (PyObject *self, void *closure)
|
|||
SYMPY_REQUIRE_VALID (self, symbol);
|
||||
|
||||
if (symbol->type () == NULL)
|
||||
{
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return py_none ().release ();
|
||||
|
||||
return type_to_type_object (symbol->type ()).release ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1118,10 +1118,7 @@ typy_richcompare (PyObject *self, PyObject *other, int op)
|
|||
/* We can only compare ourselves to another Type object, and only
|
||||
for equality or inequality. */
|
||||
if (type2 == NULL || (op != Py_EQ && op != Py_NE))
|
||||
{
|
||||
Py_INCREF (Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
return py_notimplemented ().release ();
|
||||
|
||||
if (type1 == type2)
|
||||
result = true;
|
||||
|
|
|
|||
|
|
@ -416,8 +416,7 @@ valpy_get_address (PyObject *self, void *closure)
|
|||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
val_obj->address = Py_None;
|
||||
Py_INCREF (Py_None);
|
||||
val_obj->address = py_none ().release ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue