<div dir="ltr"><div dir="ltr">Hi Laurent,<div><br></div><div>Thank you for your fix, this does indeed fix the problem.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 21 Jan 2021 at 12:44, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The Commit class and subclasses were reworked in commit 4f5d17f3a4f5<br>
("utils: checkstyle.py: Make title and files properties of commit<br>
class") with the introduction of members of the base class that were<br>
meant to be protected (not used externally, but accessible by<br>
subclasses). They have been named with a '__' prefix for this purpose,<br>
which was a bad choice as Python effectively replaces a leading '__'<br>
with a literal '__classname__' prefix to make them private<br>
(<a href="https://docs.python.org/3/tutorial/classes.html#private-variables" rel="noreferrer" target="_blank">https://docs.python.org/3/tutorial/classes.html#private-variables</a>). The<br>
members accessed in the derived classes are thus different from the ones<br>
in the base class.<br>
<br>
Fix this by replacing the double underscore prefix with a single<br>
underscore, which is a "weak internal use indicator" (as specified in<br>
<a href="https://www.python.org/dev/peps/pep-0008/" rel="noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0008/</a>), closer to the protected<br>
access specifier of C++.<br>
<br>
Reported-by: Umang Jain <<a href="mailto:email@uajain.com" target="_blank">email@uajain.com</a>><br>
Reported-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
Fixes: 4f5d17f3a4f5 ("utils: checkstyle.py: Make title and files properties of commit class")<br>
Signed-off-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br></blockquote><div><br></div><div>Tested-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
utils/checkstyle.py | 24 ++++++++++++------------<br>
1 file changed, 12 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/utils/checkstyle.py b/utils/checkstyle.py<br>
index 0e9659e98518..fb9366f8095d 100755<br>
--- a/utils/checkstyle.py<br>
+++ b/utils/checkstyle.py<br>
@@ -203,23 +203,23 @@ class CommitFile:<br>
class Commit:<br>
def __init__(self, commit):<br>
self.commit = commit<br>
- self.__parse()<br>
+ self._parse()<br>
<br>
- def __parse(self):<br>
+ def _parse(self):<br>
# Get the commit title and list of files.<br>
ret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-status',<br>
self.commit],<br>
stdout=subprocess.PIPE).stdout.decode('utf-8')<br>
files = ret.splitlines()<br>
- self.__files = [CommitFile(f) for f in files[1:]]<br>
- self.__title = files[0]<br>
+ self._files = [CommitFile(f) for f in files[1:]]<br>
+ self._title = files[0]<br>
<br>
def files(self, filter='AM'):<br>
- return [f.filename for f in self.__files if f.status in filter]<br>
+ return [f.filename for f in self._files if f.status in filter]<br>
<br>
@property<br>
def title(self):<br>
- return self.__title<br>
+ return self._title<br>
<br>
def get_diff(self, top_level, filename):<br>
diff = subprocess.run(['git', 'diff', '%s~..%s' % (self.commit, self.commit),<br>
@@ -236,11 +236,11 @@ class StagedChanges(Commit):<br>
def __init__(self):<br>
Commit.__init__(self, '')<br>
<br>
- def __parse(self):<br>
+ def _parse(self):<br>
ret = subprocess.run(['git', 'diff', '--staged', '--name-status'],<br>
stdout=subprocess.PIPE).stdout.decode('utf-8')<br>
- self.__title = "Staged changes"<br>
- self.__files = [CommitFile(f) for f in ret.splitlines()]<br>
+ self._title = "Staged changes"<br>
+ self._files = [CommitFile(f) for f in ret.splitlines()]<br>
<br>
def get_diff(self, top_level, filename):<br>
diff = subprocess.run(['git', 'diff', '--staged', '--',<br>
@@ -253,15 +253,15 @@ class Amendment(StagedChanges):<br>
def __init__(self):<br>
StagedChanges.__init__(self)<br>
<br>
- def __parse(self):<br>
+ def _parse(self):<br>
# Create a title using HEAD commit<br>
ret = subprocess.run(['git', 'show', '--pretty=oneline', '--no-patch'],<br>
stdout=subprocess.PIPE).stdout.decode('utf-8')<br>
- self.__title = 'Amendment of ' + ret.strip()<br>
+ self._title = 'Amendment of ' + ret.strip()<br>
# Extract the list of modified files<br>
ret = subprocess.run(['git', 'diff', '--staged', '--name-status', 'HEAD~'],<br>
stdout=subprocess.PIPE).stdout.decode('utf-8')<br>
- self.__files = [CommitFile(f) for f in ret.splitlines()]<br>
+ self._files = [CommitFile(f) for f in ret.splitlines()]<br>
<br>
def get_diff(self, top_level, filename):<br>
diff = subprocess.run(['git', 'diff', '--staged', 'HEAD~', '--',<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
<br>
</blockquote></div></div>