Support Python 3 in //tools/js2c.py

The script still works with Python 2.
There are no intended behaviour changes.

Bug: chromium:941669
Change-Id: I5ec63564fdb29a326c64d6ac7465f86b30ef16c1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1585857
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Cr-Commit-Position: refs/heads/master@{#61191}
This commit is contained in:
Raul Tambre 2019-04-29 20:23:24 +03:00 committed by Commit Bot
parent e4d48215ab
commit 9ebd7612da
2 changed files with 7 additions and 3 deletions

View File

@ -148,6 +148,7 @@ PhistucK <phistuck@gmail.com>
Qingyan Li <qingyan.liqy@alibaba-inc.com>
Qiuyi Zhang <qiuyi.zqy@alibaba-inc.com>
Rafal Krypa <rafal@krypa.net>
Raul Tambre <raul@tambre.ee>
Ray Glover <ray@rayglover.net>
Refael Ackermann <refack@gmail.com>
Rene Rebe <rene@exactcode.de>

View File

@ -245,7 +245,10 @@ def BuildMetadata(sources, source_bytes, native_type):
raw_sources = "".join(sources.modules)
# The sources are expected to be ASCII-only.
assert not filter(lambda value: ord(value) >= 128, raw_sources)
try:
raw_sources.encode('ascii')
except UnicodeEncodeError:
assert False
# Loop over modules and build up indices into the source blob:
get_index_cases = []
@ -300,8 +303,8 @@ def PutInt(blob_file, value):
def PutStr(blob_file, value):
PutInt(blob_file, len(value));
blob_file.write(value);
PutInt(blob_file, len(value.encode()))
blob_file.write(value.encode())
def WriteStartupBlob(sources, startup_blob):