From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 7CD113858CDA for ; Fri, 28 Jul 2023 14:50:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7CD113858CDA Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=lancelotsix.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lancelotsix.com Received: from octopus (unknown [IPv6:2a02:390:9086:0:b3e:5391:ee4d:d371]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id C146D80910; Fri, 28 Jul 2023 14:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lancelotsix.com; s=2021; t=1690555852; bh=CpT4rGBlsAfcFB3FoVJ0PKFtancoEto+RjhJYHAZOl0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KuC4jU5vVATNP3rQ7tH1EfCiikCNqk7yCPxltWf+JwZFHLijzbqwTA5hczad3k4AW xgUBxonl82Fn6auJvTtFh2fWIVwSjY+Tn9A6PNWH0iske2VFnc5Rfqdiwfz86dVkQ2 Wtao1t6FM4JO3FSsjW6+3/wFOXVAK9Hk5vaVdbepH19uGcw9MRUclUXjSTMj+0nSrw S6QPoLeaqpr4i1NS7baiuK/WnIKweErjgbl/+YFl024Yv2NmhehNzE89HmbyIiSsUk VizFe17RNtdNZYBk83xZCnneghckDHOYVUtrm0yA1iniHW8NriEwntjeTH/E3bS2PK c9XWfMbVHT+3Q== Date: Fri, 28 Jul 2023 15:50:46 +0100 From: Lancelot SIX To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/6] Rename private member of FrameDecorator Message-ID: <20230728145046.waxsfe2w2yhklkfa@octopus> References: <20230725-dap-bt-path-v1-0-bb015b0d8e54@adacore.com> <20230725-dap-bt-path-v1-1-bb015b0d8e54@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230725-dap-bt-path-v1-1-bb015b0d8e54@adacore.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (lndn.lancelotsix.com [0.0.0.0]); Fri, 28 Jul 2023 14:50:52 +0000 (UTC) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 >