From: Matthieu Longo <matthieu.longo@arm.com>
To: Tom Tromey <tom@tromey.com>
Cc: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v1] gdb/python: fix memory leak in gdb_py_tp_name
Date: Mon, 8 Jun 2026 11:31:02 +0100 [thread overview]
Message-ID: <3114bd25-227d-4cf1-83ac-3634a29d99f6@arm.com> (raw)
In-Reply-To: <87pl24hfwa.fsf@tromey.com>
On 05/06/2026 21:49, Tom Tromey wrote:
>>>>>> "Matthieu" == Matthieu Longo <matthieu.longo@arm.com> writes:
>
> Matthieu> + /* This helper should be used for cases when the called CPython function
> Matthieu> + informs the caller that an error occurred, and a Python error was set. */
> Matthieu> + auto handle_err = [&]() -> std::string
> Matthieu> + {
> Matthieu> + gdbpy_print_stack ();
> Matthieu> + PyErr_Clear ();
> Matthieu> + return NO_TYPE_NAME;
>
> The PyErr_Clear is redundant as gdbpy_print_stack guarantees that no
> error is set when it returns.
>
> Tom
Since I already merged the previous patch, can I apply this obvious fix ?
Matthieu
commit f8e8c76fbfe2a1b5b9b58add57edb24443d3c660
Author: Matthieu Longo <matthieu.longo@arm.com>
Date: Mon Jun 8 11:27:44 2026 +0100
gdb_py_tp_name: remove redundant PyErr_Clear
gdbpy_print_stack() already clears the error indicator.
Thus remove the following call to PyErr_Clear().
diff --git a/gdb/python/py-obj-type.c b/gdb/python/py-obj-type.c
index 3ed57d0cbab..bd27b255679 100644
--- a/gdb/python/py-obj-type.c
+++ b/gdb/python/py-obj-type.c
@@ -31,7 +31,6 @@ gdb_py_tp_name (PyTypeObject *py_type) noexcept
auto handle_err = [&]() -> std::string
{
gdbpy_print_stack ();
- PyErr_Clear ();
return NO_TYPE_NAME;
};
next prev parent reply other threads:[~2026-06-08 10:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 16:04 Matthieu Longo
2026-05-26 16:35 ` Tom Tromey
2026-05-28 12:46 ` Matthieu Longo
2026-05-28 16:43 ` Tom Tromey
2026-05-28 17:08 ` Matthieu Longo
2026-05-28 19:00 ` Tom Tromey
2026-05-29 10:08 ` Matthieu Longo
2026-05-29 10:52 ` Andrew Burgess
2026-05-29 13:09 ` Tom Tromey
2026-06-01 9:57 ` Matthieu Longo
2026-06-02 9:36 ` Andrew Burgess
2026-06-02 14:22 ` Tom Tromey
2026-06-03 16:30 ` Matthieu Longo
2026-06-04 9:30 ` Andrew Burgess
2026-06-05 20:49 ` Tom Tromey
2026-06-08 10:31 ` Matthieu Longo [this message]
2026-06-08 18:51 ` Andrew Burgess
2026-06-05 10:06 ` Tom de Vries
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=3114bd25-227d-4cf1-83ac-3634a29d99f6@arm.com \
--to=matthieu.longo@arm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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