From patchwork Thu Feb 9 21:24:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 19205 Received: (qmail 118601 invoked by alias); 9 Feb 2017 21:25:23 -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 118102 invoked by uid 89); 9 Feb 2017 21:25:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=1, 10, TRY, end_catch, END_CATCH X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 09 Feb 2017 21:25:07 +0000 Received: (qmail 12662 invoked by uid 0); 9 Feb 2017 21:25:06 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy6.mail.unifiedlayer.com with SMTP; 9 Feb 2017 21:25:06 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id ilR31u00V2f2jeq01lR6C0; Thu, 09 Feb 2017 14:25:06 -0700 X-Authority-Analysis: v=2.1 cv=WOnsABcR 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=n2v9WMKugxEA:10 a=zstS-IiYAAAA:8 a=VmPdoZ69VaKqZPp9u4IA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:47456 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cbwD9-0005WN-8c; Thu, 09 Feb 2017 14:25:03 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 4/7] Change one more spot to use gdbpy_ref Date: Thu, 9 Feb 2017 14:24:53 -0700 Message-Id: <20170209212456.2385-5-tom@tromey.com> In-Reply-To: <20170209212456.2385-1-tom@tromey.com> References: <20170209212456.2385-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1cbwD9-0005WN-8c X-Source-Sender: 174-16-146-181.hlrn.qwest.net (bapiya.Home) [174.16.146.181]:47456 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-02-09 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 446ad24..169c2f7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-02-09 Tom Tromey + * python/py-prettyprint.c (pretty_print_one_value): Use + gdbpy_ref. + +2017-02-09 Tom Tromey + * python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref. * python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use gdbpy_ref. 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