diff --git a/gclient.py b/gclient.py index 9dfbcd5518..ab2ccd5e97 100755 --- a/gclient.py +++ b/gclient.py @@ -241,13 +241,14 @@ class Hook(object): cmd = [arg for arg in self._action] - if cmd[0] == 'python' and six.PY2: + if cmd[0] == 'python': # If the hook specified "python" as the first item, the action is a # Python script. Run it by starting a new copy of the same interpreter if # we're running on Python 2. - # On Python 3 we simply execute 'python'. - cmd[0] = sys.executable - elif cmd[0] == 'vpython' and _detect_host_os() == 'win': + # When using vpython3, "python" refers to the Python 3 executable used by + # vpython3, so use "vpython" instead. + cmd[0] = sys.executable if six.PY2 else 'vpython' + if cmd[0] == 'vpython' and _detect_host_os() == 'win': cmd[0] += '.bat' try: @@ -2707,7 +2708,7 @@ def CMDsync(parser, args): 'url': str(d.url) if d.url else None, 'was_processed': d.should_process, } - with open(options.output_json, 'wb') as f: + with open(options.output_json, 'w') as f: json.dump({'solutions': slns}, f) return ret @@ -2862,7 +2863,7 @@ def CMDgetdep(parser, args): if client is not None: builtin_vars = client.get_builtin_vars() else: - logging.warn( + logging.warning( 'Couldn\'t find a valid gclient config. Will attempt to parse the DEPS ' 'file without support for built-in variables.') builtin_vars = None @@ -2922,7 +2923,7 @@ def CMDsetdep(parser, args): if client is not None: builtin_vars = client.get_builtin_vars() else: - logging.warn( + logging.warning( 'Couldn\'t find a valid gclient config. Will attempt to parse the DEPS ' 'file without support for built-in variables.') builtin_vars = None diff --git a/testing_support/fake_cipd.py b/testing_support/fake_cipd.py index 511a8bff69..a06fcf9b9a 100644 --- a/testing_support/fake_cipd.py +++ b/testing_support/fake_cipd.py @@ -37,7 +37,7 @@ def main(): new_content = parse_cipd(args.root, f.readlines()) # Install new packages - for path, packages in new_content.iteritems(): + for path, packages in new_content.items(): if not os.path.exists(path): os.makedirs(path) with open(os.path.join(path, '_cipd'), 'w') as f: diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index 14ee17449c..ca3986d88f 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -734,13 +734,7 @@ class GClientSmokeGIT(GClientSmokeBase): ('running', self.root_dir), # pre-deps hook ('running', self.root_dir), # pre-deps hook (fails) ] - executable = sys.executable - # On Python 3 we always execute hooks with 'python', so we cannot use - # sys.executable. - if sys.version_info.major == 3: - executable = subprocess.check_output( - ['python', '-c', 'import sys; print(sys.executable)']) - executable = executable.decode('utf-8').strip() + executable = sys.executable if sys.version_info.major == 2 else 'vpython' expected_stderr = ("Error: Command '%s -c import sys; " "sys.exit(1)' returned non-zero exit status 1 in %s\n" % (executable, self.root_dir))