From patchwork Tue Dec 25 19:53:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30837 Received: (qmail 9950 invoked by alias); 25 Dec 2018 19:54:04 -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 9856 invoked by uid 89); 25 Dec 2018 19:54:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=enhanced, H*Ad:U*tom, spots X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.145.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Dec 2018 19:54:02 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 0269F3C4B2C for ; Tue, 25 Dec 2018 13:54:01 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id bsm8gbGb0dnCebsm8gjymO; Tue, 25 Dec 2018 13:54:01 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=khP4NSmCtb99Y+UhUZv/Oz/EVvyVniL+TPYM2zBvQm8=; b=Am64HpN1iE5ULGOmt3Pb18bPgo HrdTwHDR4cLstwyXtrgAe1klH9wZAt8TSI1qJWr5Xn+q3mrVMGeTxjM6dBvbVDF2zrSR9DSoBPwKP i3u9FtSIFDJcXXbm/3dYpGxKc; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:40844 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gbsm8-003Cqk-NR; Tue, 25 Dec 2018 13:54:00 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] Use gdbpy_convert_exception in a few more spots Date: Tue, 25 Dec 2018 12:53:56 -0700 Message-Id: <20181225195358.19399-2-tom@tromey.com> In-Reply-To: <20181225195358.19399-1-tom@tromey.com> References: <20181225195358.19399-1-tom@tromey.com> I noticed a few places were converting a gdb exception to a Python exception "by hand". It's better to use the existing gdbpy_convert_exception helper function, as this handles memory errors correctly, and in the future may be enhanced in other ways. gdb/ChangeLog 2018-12-25 Tom Tromey * python/py-value.c (convert_value_from_python): Use gdbpy_convert_exception. * python/py-param.c (parmpy_init): Use gdbpy_convert_exception. * python/py-cmd.c (cmdpy_init): Use gdbpy_convert_exception. * python/py-breakpoint.c (bppy_init): Use gdbpy_convert_exception. --- gdb/ChangeLog | 9 +++++++++ gdb/python/py-breakpoint.c | 4 +--- gdb/python/py-cmd.c | 4 +--- gdb/python/py-param.c | 4 +--- gdb/python/py-value.c | 4 +--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index d144bcf2e6..29f6761554 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -874,9 +874,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) CATCH (except, RETURN_MASK_ALL) { bppy_pending_object = NULL; - PyErr_Format (except.reason == RETURN_QUIT - ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, - "%s", except.message); + gdbpy_convert_exception (except); return -1; } END_CATCH diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index d560b3a44e..0f0e298e7d 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -585,9 +585,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) xfree (docstring); xfree (pfx_name); Py_DECREF (self); - PyErr_Format (except.reason == RETURN_QUIT - ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, - "%s", except.message); + gdbpy_convert_exception (except); return -1; } END_CATCH diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index bff5d60fc2..f8b151f098 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -738,9 +738,7 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) { xfree (cmd_name); Py_DECREF (self); - PyErr_Format (except.reason == RETURN_QUIT - ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, - "%s", except.message); + gdbpy_convert_exception (except); return -1; } END_CATCH diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index d21c2faf64..430415b2f9 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1732,9 +1732,7 @@ convert_value_from_python (PyObject *obj) } CATCH (except, RETURN_MASK_ALL) { - PyErr_Format (except.reason == RETURN_QUIT - ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, - "%s", except.message); + gdbpy_convert_exception (except); return NULL; } END_CATCH