[RFA,4/5] Change one more spot to use gdbpy_ref
Commit Message
This patch changes one more spot in the Python layer to use gdbpy_ref.
2017-01-15 Tom Tromey <tom@tromey.com>
* python/py-prettyprint.c (pretty_print_one_value): Use
gdbpy_ref.
---
gdb/ChangeLog | 5 +++++
gdb/python/py-prettyprint.c | 15 ++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
Comments
On 01/15/2017 01:42 PM, Tom Tromey wrote:
> This patch changes one more spot in the Python layer to use gdbpy_ref.
>
> 2017-01-15 Tom Tromey <tom@tromey.com>
>
> * python/py-prettyprint.c (pretty_print_one_value): Use
> gdbpy_ref.
LGTM.
Thanks,
Pedro Alves
@@ -1,5 +1,10 @@
2017-01-15 Tom Tromey <tom@tromey.com>
+ * python/py-prettyprint.c (pretty_print_one_value): Use
+ gdbpy_ref.
+
+2017-01-15 Tom Tromey <tom@tromey.com>
+
* python/py-cmd.c (cmdpy_destroyer): Use gdbpy_subclass.
* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use
gdbpy_subclass.
@@ -189,21 +189,22 @@ find_pretty_printer (PyObject *value)
static PyObject *
pretty_print_one_value (PyObject *printer, struct value **out_value)
{
- PyObject *result = NULL;
+ gdbpy_ref result;
*out_value = NULL;
TRY
{
- result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
- if (result)
+ result.reset (PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst,
+ NULL));
+ if (result != NULL)
{
- if (! gdbpy_is_string (result) && ! gdbpy_is_lazy_string (result)
+ if (! gdbpy_is_string (result.get ())
+ && ! gdbpy_is_lazy_string (result.get ())
&& result != Py_None)
{
- *out_value = convert_value_from_python (result);
+ *out_value = convert_value_from_python (result.get ());
if (PyErr_Occurred ())
*out_value = NULL;
- Py_DECREF (result);
result = NULL;
}
}
@@ -213,7 +214,7 @@ pretty_print_one_value (PyObject *printer, struct value **out_value)
}
END_CATCH
- return result;
+ return result.release ();
}
/* Return the display hint for the object printer, PRINTER. Return