Commit 98e8ec5f authored by Daniel Dromboski's avatar Daniel Dromboski Committed by Commit Bot

[tools] Make tools/mb/mb.py work with Python 3

Update the way urllib is imported. As of Python 3, the old `urllib2`
was split into several smaller modules under `urllib`.

This commit unifies the resulting imported names across Python 2 and
Python 3, for forward/backward compatibility.

Bug: v8:9871
Change-Id: I81310ea83536269ae0cdf1406fd69285928c9357
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2848488Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74209}
parent 5cabf54c
......@@ -84,6 +84,7 @@ Colin Ihrig <cjihrig@gmail.com>
Cong Zuo <zckevinzc@gmail.com>
Daniel Andersson <kodandersson@gmail.com>
Daniel Bevenius <daniel.bevenius@gmail.com>
Daniel Dromboski <dandromb@gmail.com>
Daniel James <dnljms@gmail.com>
David Carlier <devnexen@gmail.com>
David Manouchehri <david@davidmanouchehri.com>
......
......@@ -27,7 +27,16 @@ import sys
import subprocess
import tempfile
import traceback
import urllib2
# for py2/py3 compatibility
try:
from urllib.parse import quote
except ImportError:
from urllib2 import quote
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from collections import OrderedDict
......@@ -1109,7 +1118,7 @@ class MetaBuildWrapper(object):
def CheckCompile(self, builder_group, builder):
url_template = self.args.url_template + '/{builder}/builds/_all?as_text=1'
url = urllib2.quote(
url = quote(
url_template.format(builder_group=builder_group, builder=builder),
safe=':/()?=')
try:
......@@ -1201,7 +1210,7 @@ class MetaBuildWrapper(object):
def Fetch(self, url):
# This function largely exists so it can be overridden for testing.
f = urllib2.urlopen(url)
f = urlopen(url)
contents = f.read()
f.close()
return contents
......
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