[lld] r356538 - Python 2/3 compatibility
Serge Guelton via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 00:42:13 PDT 2019
Author: serge_sans_paille
Date: Wed Mar 20 00:42:13 2019
New Revision: 356538
URL: http://llvm.org/viewvc/llvm-project?rev=356538&view=rev
Log:
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
Modified:
lld/trunk/utils/benchmark.py
Modified: lld/trunk/utils/benchmark.py
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/utils/benchmark.py?rev=356538&r1=356537&r2=356538&view=diff
==============================================================================
--- lld/trunk/utils/benchmark.py (original)
+++ lld/trunk/utils/benchmark.py Wed Mar 20 00:42:13 2019
@@ -13,8 +13,13 @@ import subprocess
import json
import datetime
import argparse
-import urllib
-import urllib2
+try:
+ from urllib.parse import urlencode
+ from urllib.request import urlopen, Request
+except ImportError:
+ from urllib import urlencode
+ from urllib2 import urlopen, Request
+
parser = argparse.ArgumentParser()
parser.add_argument('benchmark_directory')
@@ -126,8 +131,8 @@ def buildLntJson(benchmarks):
return json.dumps(ret, sort_keys=True, indent=4)
def submitToServer(data):
- data2 = urllib.urlencode({ 'input_data' : data }).encode('ascii')
- urllib2.urlopen(urllib2.Request(args.url, data2))
+ data2 = urlencode({ 'input_data' : data }).encode('ascii')
+ urlopen(Request(args.url, data2))
os.chdir(args.benchmark_directory)
data = buildLntJson(getBenchmarks())
More information about the llvm-commits
mailing list