Throw error for unicode URLs in .gclient

This is no longer supported to make the move to Python 3 easier.
Only some very old/weird user configurations may have this, so this provides a clear actionable error message.

Bug: 942522
Change-Id: I88106089c53d84b19c4f77b7e60fe251082122d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1539957
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Raul Tambre <raul@tambre.ee>
changes/57/1539957/5
Raul Tambre 7 years ago committed by Commit Bot
parent e2d41fe99d
commit d19589ff81

@ -1374,7 +1374,7 @@ it or fix the checkout.
''' % {'checkout_path': os.path.join(self.root_dir, dep.name),
'expected_url': dep.url,
'expected_scm': dep.GetScmName(),
'mirror_string' : mirror_string,
'mirror_string': mirror_string,
'actual_url': actual_url,
'actual_scm': dep.GetScmName()})
@ -1387,6 +1387,21 @@ it or fix the checkout.
except SyntaxError as e:
gclient_utils.SyntaxErrorToError('.gclient', e)
# Supporting Unicode URLs in both Python 2 and 3 is annoying. Try to
# convert to ASCII in case the URL doesn't actually have any Unicode
# characters, otherwise raise an error.
# This isn't an issue on Python 3 because everything's Unicode anyway.
if sys.version_info.major == 2:
try:
url = config_dict['solutions'][0]['url']
if isinstance(url, unicode):
config_dict['solutions'][0]['url'] = url.encode('ascii')
except UnicodeEncodeError:
raise gclient_utils.Error(
"Invalid .gclient file. The url mustn't be unicode.")
except KeyError:
pass
# Append any target OS that is not already being enforced to the tuple.
target_os = config_dict.get('target_os', [])
if config_dict.get('target_os_only', False):

Loading…
Cancel
Save