Revert "Drop py2 support in gerrit and git related files"
This reverts commit b5c7f4b46c3309d46e1796bce7fa83388af9bfd8.
Reason for revert: missing a replace for urlparse.urlparse
Original change's description:
> Drop py2 support in gerrit and git related files
>
> python3 is the only supported version of python in depot_tools.
>
> Bug: 1475402
> Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>
Bug: 1475402
Change-Id: Idd00fdfe0b3d62785da2789a7dfcc9fbc79b6385
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4811623
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
diff --git a/git_cl.py b/git_cl.py
index 352bf8a..b0f7efb 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -7,6 +7,8 @@
"""A git-command for integrating reviews on Gerrit."""
+from __future__ import print_function
+
import base64
import collections
import datetime
@@ -53,9 +55,14 @@
import swift_format
import watchlists
+from third_party import six
from six.moves import urllib
+if sys.version_info.major == 3:
+ basestring = (str,) # pylint: disable=redefined-builtin
+
+
__version__ = '2.0'
# Traces for git push will be stored in a traces directory inside the
@@ -915,7 +922,7 @@
if isinstance(arg, int):
return _ParsedIssueNumberArgument(issue=arg)
- if not isinstance(arg, str):
+ if not isinstance(arg, basestring):
return fail_result
if arg.isdigit():
@@ -3172,7 +3179,7 @@
return '\n'.join(self._description_lines)
def set_description(self, desc):
- if isinstance(desc, str):
+ if isinstance(desc, basestring):
lines = desc.splitlines()
else:
lines = [line.rstrip() for line in desc]