From 8b4eeffd4628a54e47ccd44e7a3f426b3218bad2 Mon Sep 17 00:00:00 2001 From: Daniel McArdle Date: Mon, 20 Jul 2020 17:02:47 +0000 Subject: [PATCH] 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 Commit-Queue: Dan McArdle --- git_cl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git_cl.py b/git_cl.py index 2166ea898..4e2ab41ae 100755 --- a/git_cl.py +++ b/git_cl.py @@ -4288,7 +4288,7 @@ def GetTreeStatus(url=None): '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 @@ def GetTreeStatusReason(): """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()