[Lldb-commits] [PATCH] D59581: Python 2/3 compat: urllib

serge via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 20 00:25:33 PDT 2019


serge-sans-paille created this revision.
serge-sans-paille added a reviewer: michaelplatings.
Herald added subscribers: llvm-commits, lldb-commits, jdoerfert.
Herald added projects: LLDB, LLVM.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D59581

Files:
  lld/utils/benchmark.py


Index: lld/utils/benchmark.py
===================================================================
--- lld/utils/benchmark.py
+++ lld/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: D59581.191443.patch
Type: text/x-patch
Size: 933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190320/d3800148/attachment.bin>


More information about the lldb-commits mailing list