Commit f1b21e46 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Make gclient.py warn on Python 3

An increasing number of Windows developers are "accidentally" ending up
with Python 3 installed on their machine through the Windows Store. If
this version is first in the path then gclient may fail in non-obvious
ways. This adds a python version check to give a clear warning message.

R=vapier@chromium.org

Change-Id: I7a292fba2ab7d059a6149644d0b1fd92d2371dce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1825945
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarMike Frysinger <vapier@chromium.org>
parent a19d3530
......@@ -118,6 +118,12 @@ import setup_color
from third_party import six
# Check for people accidentally running this script with Python3 - an
# increasingly common error on Windows 10 due to the store version of Python.
if sys.version_info.major >= 3 and not 'GCLIENT_TEST' in os.environ:
print("Warning: gclient doesn't yet support Python 3 and may not work "
"correctly.", file=sys.stderr)
# TODO(crbug.com/953884): Remove this when python3 migration is done.
if six.PY3:
......
......@@ -38,6 +38,8 @@ class GClientSmokeBase(fake_repos.FakeReposTestBase):
self.env = os.environ.copy()
self.env['DEPOT_TOOLS_UPDATE'] = '0'
self.env['DEPOT_TOOLS_METRICS'] = '0'
# Suppress Python 3 warnings and other test undesirables.
self.env['GCLIENT_TEST'] = '1'
def gclient(self, cmd, cwd=None):
if not cwd:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment