Skip to content

Commit

Permalink
Fix Py3 compat and logic/syntax in handling version.txt
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
frederickding authored and jstebbins committed Feb 28, 2019
1 parent f60354e commit 22ee1a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions make/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ def __init__( self ):

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 )
Expand Down Expand Up @@ -785,7 +786,7 @@ def _failSession( self ):
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' )
Expand Down

0 comments on commit 22ee1a3

Please sign in to comment.