]> granicus.if.org Git - handbrake/commitdiff
Fix Py3 compat and logic/syntax in handling version.txt
authorFrederick Ding <frederick@frederickding.com>
Wed, 27 Feb 2019 22:09:24 +0000 (22:09 +0000)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 28 Feb 2019 14:25:07 +0000 (06:25 -0800)
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.

make/configure.py

index 64e12556c18c7c4f62479815f50ea4cbeb494ca3..f132b9ec46212fa6fe8cb1bc3d241fd5df3e790f 100644 (file)
@@ -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' )