This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 09/13] Use gdbpy_ref in pyuw_object_attribute_to_pointer
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Sun, 20 Nov 2016 13:41:32 -0700
- Subject: [RFA 09/13] Use gdbpy_ref in pyuw_object_attribute_to_pointer
- Authentication-results: sourceware.org; auth=none
- References: <1479674496-14000-1-git-send-email-tom@tromey.com>
This changes pyuw_object_attribute_to_pointer to use gdbpy_ref.
2016-11-20 Tom Tromey <tom@tromey.com>
* python/py-unwind.c (pyuw_object_attribute_to_pointer): Use
gdbpy_ref.
---
gdb/ChangeLog | 5 +++++
gdb/python/py-unwind.c | 5 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ab0cefb..3016d3a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2016-11-20 Tom Tromey <tom@tromey.com>
+ * python/py-unwind.c (pyuw_object_attribute_to_pointer): Use
+ gdbpy_ref.
+
+2016-11-20 Tom Tromey <tom@tromey.com>
+
* python/python.c (eval_python_command, gdbpy_decode_line)
(gdbpy_run_events, gdbpy_start_type_printers)
(gdbpy_apply_type_printers): Use gdbpy_ref.
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 416223c..2c75e1d 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -177,18 +177,17 @@ pyuw_object_attribute_to_pointer (PyObject *pyo, const char *attr_name,
if (PyObject_HasAttrString (pyo, attr_name))
{
- PyObject *pyo_value = PyObject_GetAttrString (pyo, attr_name);
+ gdbpy_ref pyo_value (PyObject_GetAttrString (pyo, attr_name));
if (pyo_value != NULL && pyo_value != Py_None)
{
- rc = pyuw_value_obj_to_pointer (pyo_value, addr);
+ rc = pyuw_value_obj_to_pointer (pyo_value.get (), addr);
if (!rc)
PyErr_Format (
PyExc_ValueError,
_("The value of the '%s' attribute is not a pointer."),
attr_name);
}
- Py_XDECREF (pyo_value);
}
return rc;
}
--
2.7.4