[{"id":14654,"web_url":"https://patchwork.libcamera.org/comment/14654/","msgid":"<YAmc9Lz9c6504zpN@oden.dyn.berto.se>","date":"2021-01-21T15:25:40","subject":"Re: [libcamera-devel] [PATCH] utils: checkstyle.py: Fix \"protected\"\n\tmembers in Commit class","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your fix.\n\nOn 2021-01-21 14:44:17 +0200, Laurent Pinchart wrote:\n> The Commit class and subclasses were reworked in commit 4f5d17f3a4f5\n> (\"utils: checkstyle.py: Make title and files properties of commit\n> class\") with the introduction of members of the base class that were\n> meant to be protected (not used externally, but accessible by\n> subclasses). They have been named with a '__' prefix for this purpose,\n> which was a bad choice as Python effectively replaces a leading '__'\n> with a literal '__classname__' prefix to make them private\n> (https://docs.python.org/3/tutorial/classes.html#private-variables). The\n> members accessed in the derived classes are thus different from the ones\n> in the base class.\n> \n> Fix this by replacing the double underscore prefix with a single\n> underscore, which is a \"weak internal use indicator\" (as specified in\n> https://www.python.org/dev/peps/pep-0008/), closer to the protected\n> access specifier of C++.\n> \n> Reported-by: Umang Jain <email@uajain.com>\n> Reported-by: Naushir Patuck <naush@raspberrypi.com>\n> Fixes: 4f5d17f3a4f5 (\"utils: checkstyle.py: Make title and files properties of commit class\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  utils/checkstyle.py | 24 ++++++++++++------------\n>  1 file changed, 12 insertions(+), 12 deletions(-)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 0e9659e98518..fb9366f8095d 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -203,23 +203,23 @@ class CommitFile:\n>  class Commit:\n>      def __init__(self, commit):\n>          self.commit = commit\n> -        self.__parse()\n> +        self._parse()\n>  \n> -    def __parse(self):\n> +    def _parse(self):\n>          # Get the commit title and list of files.\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-status',\n>                                self.commit],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n>          files = ret.splitlines()\n> -        self.__files = [CommitFile(f) for f in files[1:]]\n> -        self.__title = files[0]\n> +        self._files = [CommitFile(f) for f in files[1:]]\n> +        self._title = files[0]\n>  \n>      def files(self, filter='AM'):\n> -        return [f.filename for f in self.__files if f.status in filter]\n> +        return [f.filename for f in self._files if f.status in filter]\n>  \n>      @property\n>      def title(self):\n> -        return self.__title\n> +        return self._title\n>  \n>      def get_diff(self, top_level, filename):\n>          diff = subprocess.run(['git', 'diff', '%s~..%s' % (self.commit, self.commit),\n> @@ -236,11 +236,11 @@ class StagedChanges(Commit):\n>      def __init__(self):\n>          Commit.__init__(self, '')\n>  \n> -    def __parse(self):\n> +    def _parse(self):\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-status'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        self.__title = \"Staged changes\"\n> -        self.__files = [CommitFile(f) for f in ret.splitlines()]\n> +        self._title = \"Staged changes\"\n> +        self._files = [CommitFile(f) for f in ret.splitlines()]\n>  \n>      def get_diff(self, top_level, filename):\n>          diff = subprocess.run(['git', 'diff', '--staged', '--',\n> @@ -253,15 +253,15 @@ class Amendment(StagedChanges):\n>      def __init__(self):\n>          StagedChanges.__init__(self)\n>  \n> -    def __parse(self):\n> +    def _parse(self):\n>          # Create a title using HEAD commit\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline', '--no-patch'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        self.__title = 'Amendment of ' + ret.strip()\n> +        self._title = 'Amendment of ' + ret.strip()\n>          # Extract the list of modified files\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-status', 'HEAD~'],\n>                               stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        self.__files = [CommitFile(f) for f in ret.splitlines()]\n> +        self._files = [CommitFile(f) for f in ret.splitlines()]\n>  \n>      def get_diff(self, top_level, filename):\n>          diff = subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 80739C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jan 2021 15:25:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E9BD4681F2;\n\tThu, 21 Jan 2021 16:25:43 +0100 (CET)","from mail-lj1-x233.google.com (mail-lj1-x233.google.com\n\t[IPv6:2a00:1450:4864:20::233])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC1F6681DB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jan 2021 16:25:42 +0100 (CET)","by mail-lj1-x233.google.com with SMTP id i17so2956324ljn.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jan 2021 07:25:42 -0800 (PST)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tq28sm560701lfm.86.2021.01.21.07.25.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 21 Jan 2021 07:25:41 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"YgOJZtb2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=xXWhMlS51xkHin2l5WpRRTooszGPZD1BcjmkKP821EI=;\n\tb=YgOJZtb220kFkN7Z1eRrvnfKwTuj1h7Oe0NTTdk3L7rmHi/Os4s7C7XmVvUKGua7kJ\n\t1DYnfQVYJO3DZB7HIjio9ctmggecqDR7yrzisfOPqYqDGiXPHJiSmkcsjkA02Um5P6hV\n\tW7s/cmRuvYToKcdI6k+BLk7514+MMtZS/olEzWWMtQaBjpNkapgDfimYJsUWPzWoyjgO\n\tfvNY2k7Podk2pdt/CTxz3MOTDKypKvUxiH2RuqaXUe2pnhzdHgTYuskdApm5jW9iPp5T\n\tZb18jY3FJzuXa9F2u4LBu+Yg4HTi4xXi7maoFvgZbdwYmtTtZbJV61VOwkToXnU7RmFa\n\tCf9g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=xXWhMlS51xkHin2l5WpRRTooszGPZD1BcjmkKP821EI=;\n\tb=tcry66RD72GdUDk/nsypBAgoEHVFY2tTSorzJrgR6NOCHCmio2RQo15mSaXPCwkSAU\n\tIu3n+O4qPfM+o5LvZ2PvD5bnZKJVmnpcY5Hbq+k/nu50TOjXx03sj3OnCia3LCJYMdRY\n\tLOdEMrbPy7vUt9jBdLsCMEkOkxT5KnRgp4IqzBW4Ylw6d6WbN0SgTz93l/qz/49Ift1K\n\tLAKQPwlUuBsPyFfXbKUsyxQ9sKTrIRtIiuOBQc74bOnn0JFXIMp/vQX+t++LitUiTs2e\n\tTY8/e3f+JnStGa0Trc4JGs1Q1KESc1fJMCPEJyARODsFWSToA9SC/To4us4WYiCS9SMl\n\tDHRg==","X-Gm-Message-State":"AOAM5333zGLfG4v3r0pGEGdo7Ti11P406lum76SB/1ZUJcFI/z6Cdgni\n\t9L94oiEc/xKmfo9PhJMPyzA4/QG/ZykVow==","X-Google-Smtp-Source":"ABdhPJw0G5B6CBOoIqb6YS63vrgjPH9rGR9GjrIwPB8n0svha248w6vkfsfQhjwsKEc5lufIFBO3Kg==","X-Received":"by 2002:a2e:9a58:: with SMTP id\n\tk24mr7535215ljj.259.1611242742275; \n\tThu, 21 Jan 2021 07:25:42 -0800 (PST)","Date":"Thu, 21 Jan 2021 16:25:40 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<YAmc9Lz9c6504zpN@oden.dyn.berto.se>","References":"<20210121124417.13629-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210121124417.13629-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] utils: checkstyle.py: Fix \"protected\"\n\tmembers in Commit class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14657,"web_url":"https://patchwork.libcamera.org/comment/14657/","msgid":"<CAEmqJPoCBoxTf7Mgfgww3iXaXNFz+=2jrYtVQRLnmNJpdvkR8g@mail.gmail.com>","date":"2021-01-21T15:49:18","subject":"Re: [libcamera-devel] [PATCH] utils: checkstyle.py: Fix \"protected\"\n\tmembers in Commit class","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nThank you for your fix, this does indeed fix the problem.\n\nOn Thu, 21 Jan 2021 at 12:44, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> The Commit class and subclasses were reworked in commit 4f5d17f3a4f5\n> (\"utils: checkstyle.py: Make title and files properties of commit\n> class\") with the introduction of members of the base class that were\n> meant to be protected (not used externally, but accessible by\n> subclasses). They have been named with a '__' prefix for this purpose,\n> which was a bad choice as Python effectively replaces a leading '__'\n> with a literal '__classname__' prefix to make them private\n> (https://docs.python.org/3/tutorial/classes.html#private-variables). The\n> members accessed in the derived classes are thus different from the ones\n> in the base class.\n>\n> Fix this by replacing the double underscore prefix with a single\n> underscore, which is a \"weak internal use indicator\" (as specified in\n> https://www.python.org/dev/peps/pep-0008/), closer to the protected\n> access specifier of C++.\n>\n> Reported-by: Umang Jain <email@uajain.com>\n> Reported-by: Naushir Patuck <naush@raspberrypi.com>\n> Fixes: 4f5d17f3a4f5 (\"utils: checkstyle.py: Make title and files\n> properties of commit class\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\nTested-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  utils/checkstyle.py | 24 ++++++++++++------------\n>  1 file changed, 12 insertions(+), 12 deletions(-)\n>\n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 0e9659e98518..fb9366f8095d 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -203,23 +203,23 @@ class CommitFile:\n>  class Commit:\n>      def __init__(self, commit):\n>          self.commit = commit\n> -        self.__parse()\n> +        self._parse()\n>\n> -    def __parse(self):\n> +    def _parse(self):\n>          # Get the commit title and list of files.\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline',\n> '--name-status',\n>                                self.commit],\n>\n> stdout=subprocess.PIPE).stdout.decode('utf-8')\n>          files = ret.splitlines()\n> -        self.__files = [CommitFile(f) for f in files[1:]]\n> -        self.__title = files[0]\n> +        self._files = [CommitFile(f) for f in files[1:]]\n> +        self._title = files[0]\n>\n>      def files(self, filter='AM'):\n> -        return [f.filename for f in self.__files if f.status in filter]\n> +        return [f.filename for f in self._files if f.status in filter]\n>\n>      @property\n>      def title(self):\n> -        return self.__title\n> +        return self._title\n>\n>      def get_diff(self, top_level, filename):\n>          diff = subprocess.run(['git', 'diff', '%s~..%s' % (self.commit,\n> self.commit),\n> @@ -236,11 +236,11 @@ class StagedChanges(Commit):\n>      def __init__(self):\n>          Commit.__init__(self, '')\n>\n> -    def __parse(self):\n> +    def _parse(self):\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-status'],\n>\n> stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        self.__title = \"Staged changes\"\n> -        self.__files = [CommitFile(f) for f in ret.splitlines()]\n> +        self._title = \"Staged changes\"\n> +        self._files = [CommitFile(f) for f in ret.splitlines()]\n>\n>      def get_diff(self, top_level, filename):\n>          diff = subprocess.run(['git', 'diff', '--staged', '--',\n> @@ -253,15 +253,15 @@ class Amendment(StagedChanges):\n>      def __init__(self):\n>          StagedChanges.__init__(self)\n>\n> -    def __parse(self):\n> +    def _parse(self):\n>          # Create a title using HEAD commit\n>          ret = subprocess.run(['git', 'show', '--pretty=oneline',\n> '--no-patch'],\n>\n> stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        self.__title = 'Amendment of ' + ret.strip()\n> +        self._title = 'Amendment of ' + ret.strip()\n>          # Extract the list of modified files\n>          ret = subprocess.run(['git', 'diff', '--staged', '--name-status',\n> 'HEAD~'],\n>\n> stdout=subprocess.PIPE).stdout.decode('utf-8')\n> -        self.__files = [CommitFile(f) for f in ret.splitlines()]\n> +        self._files = [CommitFile(f) for f in ret.splitlines()]\n>\n>      def get_diff(self, top_level, filename):\n>          diff = subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D8E1FBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jan 2021 15:49:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6689B681F6;\n\tThu, 21 Jan 2021 16:49:36 +0100 (CET)","from mail-qk1-x733.google.com (mail-qk1-x733.google.com\n\t[IPv6:2607:f8b0:4864:20::733])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB5C5681E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jan 2021 16:49:35 +0100 (CET)","by mail-qk1-x733.google.com with SMTP id 143so2021457qke.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jan 2021 07:49:35 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"onIXthOq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=8/p2N+fzdouF1AO/pE5RW5aNhZJfqz0WGQPF3pzpzSE=;\n\tb=onIXthOqVIooVtoQ/Grby3yKIJ1OdQfZf8sziYEAPWC2ZiZl6lLOXnFtIe2jeHOmUv\n\tch1iPRkJ0JF7aBh0szquaXxM5pY9PwF3r+N/sFyaHulBvWsWYyuaVIwBAOEmOwhuSBs3\n\tB6YvooUxBzTJ5sSCR1zz9lU/m2YQAqz+uXXYN9aATBSrePc/+xpNfqE9bIyBaGadwDTv\n\tgZO9v9kj6+SgpUOw2Uz3S7VHPgHzwnFdYMKrxMXjZ0SOV78RvUDLiqwLz+N25E/vcst5\n\tRhvVpE7oXcxVPrkENH4vXPfSnnRUW20YzInLo/M+NypccQl83CqZUn5p6vCSJo5VwwjP\n\t/xdg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=8/p2N+fzdouF1AO/pE5RW5aNhZJfqz0WGQPF3pzpzSE=;\n\tb=GXN22GeM5kJSTdcycfqc8+YmqiVKuxPmFqxRbxsbAFBWPWSczgVlpwuDdomwTebcL2\n\thvKcR9iO6hFDBePlF4xzDWw2Sk41y/sNl468rnnNWGVz9y7IPJEqzdDB+dcSNpv2RKsL\n\tRKBae8YSnUzKz+GWEwodK5hp5+kecFqRpdgbaq2KmpXPsQKpLr0PaXP1az4g0b66k+S4\n\t2MVj6MWJcRg57KAHKif6xmVfaw5xfupSNg1BJaLmz2WCg2zCmuCRY1Z9eRQ2qEMAC86O\n\tN0P8l1Jw6231o64aogCxplAas3lO6Q/PXYmIzClrzvff5ZTWlpMPJSTtmFm/8QJDipDt\n\tA6/Q==","X-Gm-Message-State":"AOAM53206NlsJ7e9L2p1Afxanl5nuZQtD0XfZ31XiIV++PZxPwMl42TB\n\ttV3TuY26bOe9tPSD6TGP4Bhbi+Aa7w8w17x5pqZa9Q==","X-Google-Smtp-Source":"ABdhPJwGJ0sqqkzqPfJRiMH+eEt4p1bsMW/UIGfgRwK9jWjYC0mq6NXhPQSGe/aIKT+S0GyGuXDaRe+IMTJS3KIeTCo=","X-Received":"by 2002:a37:eca:: with SMTP id 193mr343409qko.261.1611244174353; \n\tThu, 21 Jan 2021 07:49:34 -0800 (PST)","MIME-Version":"1.0","References":"<20210121124417.13629-1-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20210121124417.13629-1-laurent.pinchart@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Thu, 21 Jan 2021 15:49:18 +0000","Message-ID":"<CAEmqJPoCBoxTf7Mgfgww3iXaXNFz+=2jrYtVQRLnmNJpdvkR8g@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] utils: checkstyle.py: Fix \"protected\"\n\tmembers in Commit class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/mixed;\n\tboundary=\"===============1676906401896238630==\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]