Use gdbpy_ref in instantiate_pretty_printer

This changes instantiate_pretty_printer to use gdbpy_ref, removing a
call to Py_DECREF.

gdb/ChangeLog
2020-12-11  Tom Tromey  <tom@tromey.com>

	* varobj.c (instantiate_pretty_printer): Use gdbpy_ref.
This commit is contained in:
Tom Tromey
2020-12-11 09:33:36 -07:00
parent 446d2c032d
commit 1345dee280
2 changed files with 7 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2020-12-11 Tom Tromey <tom@tromey.com>
* varobj.c (instantiate_pretty_printer): Use gdbpy_ref.
2020-12-11 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_clear_saved_item): Remove.

View File

@ -459,16 +459,11 @@ varobj_delete (struct varobj *var, bool only_children)
static PyObject *
instantiate_pretty_printer (PyObject *constructor, struct value *value)
{
PyObject *val_obj = NULL;
PyObject *printer;
val_obj = value_to_value_object (value);
if (! val_obj)
gdbpy_ref<> val_obj (value_to_value_object (value));
if (val_obj == nullptr)
return NULL;
printer = PyObject_CallFunctionObjArgs (constructor, val_obj, NULL);
Py_DECREF (val_obj);
return printer;
return PyObject_CallFunctionObjArgs (constructor, val_obj.get (), NULL);
}
#endif