git-cl: Fix "git cl tree" issues with Python 3.
* First, we were treating the return value of HTTPResponse.read() as a
string when it is really a byte string.
* Second, the urlparse library was renamed to urllib.parse in Python 3,
so I made the appropriate substitution.
Change-Id: I0b23716e990eca8ddf77742f378ab54eda3d3717
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2307509
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dan McArdle <dmcardle@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 2166ea8..4e2ab41 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -4288,7 +4288,7 @@
'unknown' or 'unset'."""
url = url or settings.GetTreeStatusUrl(error_ok=True)
if url:
- status = urllib.request.urlopen(url).read().lower()
+ status = str(urllib.request.urlopen(url).read().lower())
if status.find('closed') != -1 or status == '0':
return 'closed'
elif status.find('open') != -1 or status == '1':
@@ -4301,7 +4301,7 @@
"""Fetches the tree status from a json url and returns the message
with the reason for the tree to be opened or closed."""
url = settings.GetTreeStatusUrl()
- json_url = urlparse.urljoin(url, '/current?format=json')
+ json_url = urllib.parse.urljoin(url, '/current?format=json')
connection = urllib.request.urlopen(json_url)
status = json.loads(connection.read())
connection.close()