From: Frederick Ding Date: Wed, 27 Feb 2019 22:09:24 +0000 (+0000) Subject: Fix Py3 compat and logic/syntax in handling version.txt X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22ee1a38eac473ce81d487f88ca58382abbaa0cb;p=handbrake Fix Py3 compat and logic/syntax in handling version.txt The first fix addresses the problem that readlines() gives back a list of strings, which do not have the `.decode()` method that bytes do. But `_parseSession()` is used both for the bytes output by running `repo-info.sh` and for the strings output by ingesting `version.txt`. So we still need to handle the bytes case. The second fix addresses syntax and logic problems. If a string is not empty, `if self.hash` will check that it's non-empty (I don't think `is not empty` actually works -- it has given me a NameError). And the string comparison should be done by value equality, not reference equality. --- diff --git a/make/configure.py b/make/configure.py index 64e12556c..f132b9ec4 100644 --- a/make/configure.py +++ b/make/configure.py @@ -718,7 +718,8 @@ class RepoProbe( ShellProbe ): def _parseSession( self ): for line in self.session: - line = line.decode('utf-8') + if isinstance(line, bytes): + line = line.decode('utf-8') ## grok fields m = re.match( '([^\=]+)\=(.*)', line ) @@ -785,7 +786,7 @@ class RepoProbe( ShellProbe ): self.session = in_file.readlines() if self.session: self._parseSession() - if self.hash is not empty and self.hash is not 'deadbeaf': + if self.hash and self.hash != 'deadbeaf': cfg.infof( '(pass)\n' ) else: cfg.infof( '(fail)\n' )