Skip to content

Commit a1aa7a4

Browse files
author
Serge Guelton
committed
Python 2/3 compatibility
This should be the only change required to have lld's python code base compatible with both Python 2 and Python 3 Differential Revision: https://reviews.llvm.org/D59538 llvm-svn: 356538
1 parent dfa0fdb commit a1aa7a4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lld/utils/benchmark.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
import json
1414
import datetime
1515
import argparse
16-
import urllib
17-
import urllib2
16+
try:
17+
from urllib.parse import urlencode
18+
from urllib.request import urlopen, Request
19+
except ImportError:
20+
from urllib import urlencode
21+
from urllib2 import urlopen, Request
22+
1823

1924
parser = argparse.ArgumentParser()
2025
parser.add_argument('benchmark_directory')
@@ -126,8 +131,8 @@ def buildLntJson(benchmarks):
126131
return json.dumps(ret, sort_keys=True, indent=4)
127132

128133
def submitToServer(data):
129-
data2 = urllib.urlencode({ 'input_data' : data }).encode('ascii')
130-
urllib2.urlopen(urllib2.Request(args.url, data2))
134+
data2 = urlencode({ 'input_data' : data }).encode('ascii')
135+
urlopen(Request(args.url, data2))
131136

132137
os.chdir(args.benchmark_directory)
133138
data = buildLntJson(getBenchmarks())

0 commit comments

Comments
 (0)