Improve gclient Python 3 compatibility
This enables gclient sync and gclient runhooks to run, barring hook script failures.
git cl upload also now works.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 942522
Change-Id: I2ac587b5f803ba7f5bb5e412337ce049f4b1a741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1524583
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
diff --git a/git_cache.py b/git_cache.py
index 9e23905..f17f466 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -6,6 +6,7 @@
"""A git command for managing a local cache of git repositories."""
from __future__ import print_function
+
import contextlib
import errno
import logging
@@ -17,7 +18,12 @@
import time
import subprocess
import sys
-import urlparse
+
+try:
+ import urlparse
+except ImportError: # For Py3 compatibility
+ import urllib.parse as urlparse
+
import zipfile
from download_from_google_storage import Gsutil