From: Lancelot SIX <lsix@lancelotsix.com>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/6] Rename private member of FrameDecorator
Date: Fri, 28 Jul 2023 15:50:46 +0100 [thread overview]
Message-ID: <20230728145046.waxsfe2w2yhklkfa@octopus> (raw)
In-Reply-To: <20230725-dap-bt-path-v1-1-bb015b0d8e54@adacore.com>
On Tue, Jul 25, 2023 at 07:49:38AM -0600, Tom Tromey via Gdb-patches wrote:
> In Python, a member name starting with "__" is specially handled to
> make it private to the class. This patch ensures that this is done
> for the private method of FrameDecorator.
Hi,
My understanding is that the "__" prefix is more a syntactic sugar to
avoid name clashes with subclasses than making it strictly private[1].
In this case, the method still exists as
FrameDecorator._FrameDecorator__is_limited_frame, which can be accessed
from outside of FrameDecorator. I agree it can be less intuitive to
access this method from a subclass as one would need to call
self._FrameDecorator__is_limited_frame, which is probably what you are
looking for.
I do not object to this change, I am just noting that nothing is really
private in Python, and it seems to me that the commit message promises
otherwise.
Best,
Lancelot.
[1] https://docs.python.org/3/tutorial/classes.html#private-variables
> ---
> gdb/python/lib/gdb/FrameDecorator.py | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py
> index 050cb934b7c..c4a7806e434 100644
> --- a/gdb/python/lib/gdb/FrameDecorator.py
> +++ b/gdb/python/lib/gdb/FrameDecorator.py
> @@ -53,7 +53,7 @@ class FrameDecorator(object):
> self._base = base
>
> @staticmethod
> - def _is_limited_frame(frame):
> + def __is_limited_frame(frame):
> """Internal utility to determine if the frame is special or
> limited."""
> sal = frame.find_sal()
> @@ -148,7 +148,7 @@ class FrameDecorator(object):
> return self._base.frame_args()
>
> frame = self.inferior_frame()
> - if self._is_limited_frame(frame):
> + if self.__is_limited_frame(frame):
> return None
>
> args = FrameVars(frame)
> @@ -164,7 +164,7 @@ class FrameDecorator(object):
> return self._base.frame_locals()
>
> frame = self.inferior_frame()
> - if self._is_limited_frame(frame):
> + if self.__is_limited_frame(frame):
> return None
>
> args = FrameVars(frame)
> @@ -179,7 +179,7 @@ class FrameDecorator(object):
> return self._base.line()
>
> frame = self.inferior_frame()
> - if self._is_limited_frame(frame):
> + if self.__is_limited_frame(frame):
> return None
>
> sal = frame.find_sal()
>
> --
> 2.40.1
>
next prev parent reply other threads:[~2023-07-28 14:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 13:49 [PATCH 0/6] Several DAP fixes for VSCode Tom Tromey
2023-07-25 13:49 ` [PATCH 1/6] Rename private member of FrameDecorator Tom Tromey
2023-07-28 14:50 ` Lancelot SIX [this message]
2023-07-31 14:30 ` Tom Tromey
2023-07-31 14:36 ` Lancelot SIX
2023-07-25 13:49 ` [PATCH 2/6] Refactor dap_launch Tom Tromey
2023-07-25 13:49 ` [PATCH 3/6] Add "cwd" parameter to DAP launch request Tom Tromey
2023-07-25 14:07 ` Eli Zaretskii
2023-07-25 13:49 ` [PATCH 4/6] Full paths in DAP stackTrace responses Tom Tromey
2023-07-28 15:29 ` Lancelot SIX
2023-07-31 16:26 ` Tom Tromey
2023-07-25 13:49 ` [PATCH 5/6] Move DAP breakpoint event code to breakpoint.py Tom Tromey
2023-07-25 13:49 ` [PATCH 6/6] Do not send "new breakpoint" event when breakpoint is set Tom Tromey
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=20230728145046.waxsfe2w2yhklkfa@octopus \
--to=lsix@lancelotsix.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).