[PATCH] D59538: Python 2/3 compatibility

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 00:42:51 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL356538: Python 2/3 compatibility (authored by serge_sans_paille, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59538?vs=191267&id=191456#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59538/new/

https://reviews.llvm.org/D59538

Files:
  lld/trunk/utils/benchmark.py


Index: lld/trunk/utils/benchmark.py
===================================================================
--- lld/trunk/utils/benchmark.py
+++ lld/trunk/utils/benchmark.py
@@ -13,8 +13,13 @@
 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 @@
     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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59538.191456.patch
Type: text/x-patch
Size: 951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190320/8a649442/attachment-0001.bin>


More information about the llvm-commits mailing list