From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 4/5] Change one more spot to use gdbpy_ref
Date: Sun, 15 Jan 2017 13:43:00 -0000 [thread overview]
Message-ID: <20170115134253.24018-5-tom@tromey.com> (raw)
In-Reply-To: <20170115134253.24018-1-tom@tromey.com>
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(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 61e4ca4..c32192d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index d6d157a..6132201 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -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
--
2.9.3
next prev parent reply other threads:[~2017-01-15 13:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 13:43 [RFA 0/5] more cleanup removal in Python Tom Tromey
2017-01-15 13:43 ` [RFA 5/5] Remove some gotos from Python Tom Tromey
2017-02-09 13:03 ` Pedro Alves
2017-01-15 13:43 ` [RFA 2/5] Introduce ui_file_up and use it to remove cleanups Tom Tromey
2017-01-16 9:59 ` Trevor Saunders
2017-01-16 17:58 ` Pedro Alves
2017-01-16 19:08 ` Tom Tromey
2017-01-17 1:40 ` Pedro Alves
2017-01-17 19:05 ` Tom Tromey
2017-01-15 13:43 ` [RFA 3/5] Introduce gdbpy_subclass and use it to simplify some logic Tom Tromey
2017-01-24 20:21 ` Simon Marchi
2017-02-09 11:44 ` Pedro Alves
2017-02-09 18:52 ` Tom Tromey
2017-02-09 13:00 ` Pedro Alves
2017-01-15 13:43 ` Tom Tromey [this message]
2017-02-09 12:52 ` [RFA 4/5] Change one more spot to use gdbpy_ref Pedro Alves
2017-01-15 13:43 ` [RFA 1/5] Remove some ui_out-related cleanups from Python Tom Tromey
2017-01-15 21:52 ` Simon Marchi
2017-01-16 16:13 ` Tom Tromey
2017-01-16 11:19 ` Trevor Saunders
2017-02-08 17:28 ` Pedro Alves
2017-02-08 22:27 ` Pedro Alves
2017-02-08 23:05 ` Tom Tromey
2017-02-08 23:52 ` Pedro Alves
2017-02-09 4:34 ` Matt Rice
2017-02-09 12:48 ` Pedro Alves
2017-02-09 12:51 ` Pedro Alves
2017-02-09 15:46 ` Matt Rice
2017-02-09 16:04 ` Simon Marchi
2017-02-10 6:47 ` Trevor Saunders
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170115134253.24018-5-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).