diff options
author | Tom Tromey <tom@tromey.com> | 2017-01-12 07:46:07 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-02-10 12:24:33 -0700 |
commit | 1bdfaf42ac152bb30e2b3ae3ab67b241835bba44 (patch) | |
tree | 6dfaf8532f09168e60e14f50d712def1f79a5668 /gdb/python | |
parent | 88b6faea9953505e9e8a7a77995c7db5dfb6ac19 (diff) | |
download | gdb-1bdfaf42ac152bb30e2b3ae3ab67b241835bba44.zip gdb-1bdfaf42ac152bb30e2b3ae3ab67b241835bba44.tar.gz gdb-1bdfaf42ac152bb30e2b3ae3ab67b241835bba44.tar.bz2 |
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.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-prettyprint.c | 15 |
1 files changed, 8 insertions, 7 deletions
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 |