From patchwork Sun Jan 15 13:42:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 18909 Received: (qmail 127775 invoked by alias); 15 Jan 2017 13:43:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 127404 invoked by uid 89); 15 Jan 2017 13:43:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*RU:cmgw3, Hx-spam-relays-external:cmgw3, H*r:cmgw3, Hx-spam-relays-external:10.0.90.84 X-HELO: gproxy9.mail.unifiedlayer.com Received: from gproxy9-pub.mail.unifiedlayer.com (HELO gproxy9.mail.unifiedlayer.com) (69.89.20.122) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 15 Jan 2017 13:43:03 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy9.mail.unifiedlayer.com (Postfix) with ESMTP id 32D5C1E0940 for ; Sun, 15 Jan 2017 06:43:02 -0700 (MST) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id Ydiz1u0052f2jeq01dj2Tr; Sun, 15 Jan 2017 06:43:02 -0700 X-Authority-Analysis: v=2.1 cv=YuCcGeoX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IgFoBzBjUZAA:10 a=zstS-IiYAAAA:8 a=h1slKAPncxHXYZrO7ScA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:40602 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cSl5G-0002Lj-Uo; Sun, 15 Jan 2017 06:42:59 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 4/5] Change one more spot to use gdbpy_ref Date: Sun, 15 Jan 2017 06:42:52 -0700 Message-Id: <20170115134253.24018-5-tom@tromey.com> In-Reply-To: <20170115134253.24018-1-tom@tromey.com> References: <20170115134253.24018-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1cSl5G-0002Lj-Uo X-Source-Sender: 174-16-146-181.hlrn.qwest.net (bapiya.Home) [174.16.146.181]:40602 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This patch changes one more spot in the Python layer to use gdbpy_ref. 2017-01-15 Tom Tromey * 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 + * python/py-prettyprint.c (pretty_print_one_value): Use + gdbpy_ref. + +2017-01-15 Tom Tromey + * 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