Skip to content

Commit bbdb786

Browse files
winksavillecommit-bot@chromium.org
authored andcommitted
[build]: Build on Arch Linux with python 2.7-3.8
This change allow builds to succeed on Arch Linux with python 2.7, 3.7.4 and 3.8. Otherwise it fails with python 3.7.4 and 3.8. - bin_to_assembly.py Using ord(byte) here is an error on python 3.x use a conditional expression instead. - create_archive.py Using ord(byte) here is an error on python 3.x use a conditional expression instead. Use `as inst` syntax which is required by 3.x - create_string_literal.py - gen_library_src_paths.py Use `as inst` syntax which is required by 3.x - make_version.py print >> sys.stderr syntax is not supported by 3.x use file=sys.stderr and add `from __future__ import print_function` vmhash.update requires a string use encode('utf-8') versopm+cc+text.replace requires a str so use `decode`. Test: No added tests as there are no behavioral changes. Change-Id: Id9b0a3187d06ad2b2dce3cf2244144393caddc9a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124211 Commit-Queue: Alexander Thomas <athom@google.com> Reviewed-by: Alexander Thomas <athom@google.com>
1 parent 64e65a7 commit bbdb786

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

runtime/tools/bin_to_assembly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def Main():
8383
with open(options.input, "rb") as input_file:
8484
if options.target_os in ["win"]:
8585
for byte in input_file.read():
86-
output_file.write("byte %d\n" % ord(byte))
86+
output_file.write("byte %d\n" % (byte if isinstance(byte, int) else ord(byte)))
8787
size += 1
8888
else:
8989
for byte in input_file.read():
90-
output_file.write(".byte %d\n" % ord(byte))
90+
output_file.write(".byte %d\n" % (byte if isinstance(byte, int) else ord(byte)))
9191
size += 1
9292

9393
if options.target_os not in ["mac", "ios", "win"]:

runtime/tools/create_archive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def WriteCCFile(
9898
line = ' '
9999
lineCounter = 0
100100
for byte in tar_archive:
101-
line += r" %d," % ord(byte)
101+
line += r" %d," % (byte if isinstance(byte, int) else ord(byte))
102102
lineCounter += 1
103103
if lineCounter == 10:
104104
out.write(line + '\n')
@@ -180,7 +180,7 @@ def Main(args):
180180
else:
181181
return MakeCCFile(options)
182182

183-
except Exception, inst:
183+
except Exception as inst:
184184
sys.stderr.write('create_archive.py exception\n')
185185
sys.stderr.write(str(inst))
186186
sys.stderr.write('\n')

runtime/tools/create_string_literal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def main(args):
8585
return -1
8686

8787
return 0
88-
except Exception, inst:
88+
except Exception as inst:
8989
sys.stderr.write('create_string_literal.py exception\n')
9090
sys.stderr.write(str(inst))
9191
sys.stderr.write('\n')

runtime/tools/gen_library_src_paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def main(args):
126126
return -1
127127

128128
return 0
129-
except Exception, inst:
129+
except Exception as inst:
130130
sys.stderr.write('gen_library_src_paths.py exception\n')
131131
sys.stderr.write(str(inst))
132132
sys.stderr.write('\n')

tools/make_version.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66
# This python script creates a version string in a C++ file.
77

8+
from __future__ import print_function
9+
810
import hashlib
911
import os
1012
import sys
@@ -14,7 +16,7 @@
1416

1517

1618
def debugLog(message):
17-
print >> sys.stderr, message
19+
print(message, file=sys.stderr)
1820
sys.stderr.flush()
1921

2022

@@ -77,7 +79,7 @@ def MakeSnapshotHashString():
7779
for vmfilename in VM_SNAPSHOT_FILES:
7880
vmfilepath = os.path.join(utils.DART_DIR, 'runtime', 'vm', vmfilename)
7981
with open(vmfilepath) as vmfile:
80-
vmhash.update(vmfile.read())
82+
vmhash.update(vmfile.read().encode('utf-8'))
8183
return vmhash.hexdigest()
8284

8385

@@ -97,7 +99,7 @@ def MakeFile(quiet,
9799
version_time = utils.GetGitTimestamp()
98100
if no_git_hash or version_time == None:
99101
version_time = "Unknown timestamp"
100-
version_cc_text = version_cc_text.replace("{{COMMIT_TIME}}", version_time)
102+
version_cc_text = version_cc_text.replace("{{COMMIT_TIME}}", version_time.decode("utf-8"))
101103
abi_version = utils.GetAbiVersion(version_file)
102104
version_cc_text = version_cc_text.replace("{{ABI_VERSION}}", abi_version)
103105
oldest_supported_abi_version = utils.GetOldestSupportedAbiVersion(

0 commit comments

Comments
 (0)