Return str in describe() as said by the blurb.
diff --git a/utils/update_build_version.py b/utils/update_build_version.py
index 69b4289..9828f8a 100755
--- a/utils/update_build_version.py
+++ b/utils/update_build_version.py
@@ -57,13 +57,18 @@
Runs 'git describe', or alternately 'git rev-parse HEAD', in dir. If
successful, returns the output; otherwise returns 'unknown hash, <date>'."""
try:
- return command_output(['git', 'describe'], dir).rstrip()
+ # decode() is needed here for Python3 compatibility. In Python2,
+ # str and bytes are the same type, but not in Python3.
+ # Popen.communicate() returns a bytes instance, which needs to be
+ # decoded into text data first in Python3. And this decode() won't
+ # hurt Python2.
+ return command_output(['git', 'describe'], dir).rstrip().decode()
except:
try:
- return command_output(['git', 'rev-parse', 'HEAD'], dir).rstrip()
+ return command_output(
+ ['git', 'rev-parse', 'HEAD'], dir).rstrip().decode()
except:
- return 'unknown hash, {}'.format(
- datetime.date.today().isoformat()).encode('ascii')
+ return 'unknown hash, {}'.format(datetime.date.today().isoformat())
def main():
@@ -72,12 +77,7 @@
sys.exit(1)
new_content = '"spirv-tools {}\\n"\n'.format(
- # decode() is needed here for Python3 compatibility. In Python2,
- # str and bytes are the same type, but not in Python3.
- # Popen.communicate() returns a bytes instance, which needs to be
- # decoded into text data first in Python3. And this decode() won't
- # hurt Python2.
- describe(sys.argv[1]).decode('ascii').replace('"', '\\"'))
+ describe(sys.argv[1]).replace('"', '\\"'))
if os.path.isfile(OUTFILE) and new_content == open(OUTFILE, 'r').read():
sys.exit(0)
open(OUTFILE, 'w').write(new_content)