Commit 180f017f authored by Vadim Gorbachev's avatar Vadim Gorbachev Committed by Commit Bot

Preparing v8 to use with python3

There are now less that 100 days until the end of life
of Python 2(aka _legacy_ Python) https://pythonclock.org/ .
The code compatibility check for python2 and python3
used the following tools: futurize, flake8

Related tasks:
1. https://github.com/nodejs/node/issues/24512
2. https://github.com/v8/v8/pull/35

Bug: v8:8594
Change-Id: Ia081a158a2b41cd880a5d47bb340f21858340d42
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1864942
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64381}
parent c48096d4
...@@ -66,7 +66,9 @@ class TestSuite(testsuite.TestSuite): ...@@ -66,7 +66,9 @@ class TestSuite(testsuite.TestSuite):
testsource = testsource.replace("$" + key, replacement[key]); testsource = testsource.replace("$" + key, replacement[key]);
Test(testname, testsource, expectation) Test(testname, testsource, expectation)
return MkTest return MkTest
execfile(pathname, {"Test": Test, "Template": Template}) with open(pathname) as f:
text = f.read()
exec(text, {"Test": Test, "Template": Template})
def ListTests(self): def ListTests(self):
result = [] result = []
......
...@@ -24,7 +24,7 @@ def parse(file, seqlen): ...@@ -24,7 +24,7 @@ def parse(file, seqlen):
r'(:?\.|\()(?P<char>\.|\w)(:?\.|\)), bc = (?P<bc>\w+), .*') r'(:?\.|\()(?P<char>\.|\w)(:?\.|\)), bc = (?P<bc>\w+), .*')
total = 0 total = 0
bc_cnt = [None] * seqlen bc_cnt = [None] * seqlen
for i in xrange(seqlen): for i in range(seqlen):
bc_cnt[i] = {} bc_cnt[i] = {}
last = [None] * seqlen last = [None] * seqlen
with open(file) as f: with open(file) as f:
...@@ -32,14 +32,14 @@ def parse(file, seqlen): ...@@ -32,14 +32,14 @@ def parse(file, seqlen):
while l: while l:
l = l.strip() l = l.strip()
if l.startswith("Start bytecode interpreter"): if l.startswith("Start bytecode interpreter"):
for i in xrange(seqlen): for i in range(seqlen):
last[i] = collections.deque(maxlen=i+1) last[i] = collections.deque(maxlen=i+1)
match = rx.search(l) match = rx.search(l)
if match: if match:
total += 1 total += 1
bc = match.group('bc') bc = match.group('bc')
for i in xrange(seqlen): for i in range(seqlen):
last[i].append(bc) last[i].append(bc)
key = ' --> '.join(last[i]) key = ' --> '.join(last[i])
bc_cnt[i][key] = bc_cnt[i].get(key,0) + 1 bc_cnt[i][key] = bc_cnt[i].get(key,0) + 1
...@@ -57,7 +57,7 @@ def print_most_common(d, seqlen, total): ...@@ -57,7 +57,7 @@ def print_most_common(d, seqlen, total):
def main(argv): def main(argv):
max_seq = 7 max_seq = 7
bc_cnt, total = parse(argv[1],max_seq) bc_cnt, total = parse(argv[1],max_seq)
for i in xrange(max_seq): for i in range(max_seq):
print() print()
print("Most common of length {}".format(i+1)) print("Most common of length {}".format(i+1))
print() print()
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# Use of this source code is governed by a BSD-style license that can be found # Use of this source code is governed by a BSD-style license that can be found
# in the LICENSE file. # in the LICENSE file.
from __future__ import print_function
import argparse import argparse
import io import io
import sys import sys
...@@ -34,10 +35,10 @@ if __name__ == "__main__": ...@@ -34,10 +35,10 @@ if __name__ == "__main__":
section_name_bs = fin.read(section_name_length) section_name_bs = fin.read(section_name_length)
if section_name_bs == "compilationHints": if section_name_bs == "compilationHints":
num_hints, bs = read_varuintN(fin) num_hints, bs = read_varuintN(fin)
print "Custom section compilationHints with", num_hints, "hints:" print("Custom section compilationHints with ", num_hints, "hints:")
for i in range(num_hints): for i in range(num_hints):
hint, bs = read_uint8(fin) hint, bs = read_uint8(fin)
print i, hex(hint) print(i, " ", hex(hint))
else: else:
remaining_length = payload_length \ remaining_length = payload_length \
- len(section_name_length_bs) \ - len(section_name_length_bs) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment