This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Change one more spot to use gdbpy_ref
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 10 Feb 2017 19:35:44 -0000
- Subject: [binutils-gdb] Change one more spot to use gdbpy_ref
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1bdfaf42ac152bb30e2b3ae3ab67b241835bba44
commit 1bdfaf42ac152bb30e2b3ae3ab67b241835bba44
Author: Tom Tromey <tom@tromey.com>
Date: Thu Jan 12 07:46:07 2017 -0700
Change one more spot to use gdbpy_ref
This patch changes one more spot in the Python layer to use gdbpy_ref.
gdb/ChangeLog
2017-02-10 Tom Tromey <tom@tromey.com>
* python/py-prettyprint.c (pretty_print_one_value): Use
gdbpy_ref.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/python/py-prettyprint.c | 15 ++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 96cd417..6b449f0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2017-02-10 Tom Tromey <tom@tromey.com>
+ * python/py-prettyprint.c (pretty_print_one_value): Use
+ gdbpy_ref.
+
+2017-02-10 Tom Tromey <tom@tromey.com>
+
* python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref.
* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use
gdbpy_ref.
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index e0d2110..66929bf 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -190,21 +190,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;
}
}
@@ -214,7 +215,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