From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id D3TQOeXVw2S3pzEAWB0awg (envelope-from ) for ; Fri, 28 Jul 2023 10:51:17 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=uwziSyrg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E1FED1E0C0; Fri, 28 Jul 2023 10:51:17 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C7CE31E092 for ; Fri, 28 Jul 2023 10:51:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C4C23855593 for ; Fri, 28 Jul 2023 14:51:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C4C23855593 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690555874; bh=r0DKCysq27zGfpLXS6PlIKVXNgG0ptQEEfKK3vnQo08=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=uwziSyrgnH4mVZBYoW38IxsiCrlnsqozAaBupNybihim9eA0Vd5EzDkyUOt4DlL6o 3hr3hkS7YOJzkGBMxIzP/tmpIr1qEOiU5HmzCWgJz0dfJp0+LvDZAdPj51a89DUk4A iCYBlHN/SORTqPf6QW18qpIy/FqFgqUtV775KpCA= 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 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) Date: Fri, 28 Jul 2023 15:50:46 +0100 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 >