diff --git a/cit b/cit index 410341ff9..db4c605e8 100755 --- a/cit +++ b/cit @@ -5,4 +5,4 @@ base_dir=$(dirname "$0") -PYTHONDONTWRITEBYTECODE=1 exec python "$base_dir/cit.py" "$@" +PYTHONDONTWRITEBYTECODE=1 exec python3 "$base_dir/cit.py" "$@" diff --git a/cit.bat b/cit.bat index 82919b936..c1157ecfe 100755 --- a/cit.bat +++ b/cit.bat @@ -9,4 +9,4 @@ setlocal set PATH=%PATH%;%~dp0 :: Defer control. -python "%~dp0\cit.py" %* +python3 "%~dp0\cit.py" %* diff --git a/cit.py b/cit.py index 09de655db..3058f44fe 100755 --- a/cit.py +++ b/cit.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2015 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. diff --git a/clang-format b/clang-format index c3715403e..35a1168de 100755 --- a/clang-format +++ b/clang-format @@ -5,4 +5,4 @@ base_dir=$(dirname "$0") -PYTHONDONTWRITEBYTECODE=1 exec python "$base_dir/clang_format.py" "$@" +PYTHONDONTWRITEBYTECODE=1 exec python3 "$base_dir/clang_format.py" "$@" diff --git a/clang-format.bat b/clang-format.bat index c3bb53bc4..4e0c80f34 100644 --- a/clang-format.bat +++ b/clang-format.bat @@ -9,4 +9,4 @@ setlocal set PATH=%PATH%;%~dp0 :: Defer control. -python "%~dp0\clang_format.py" %* +python3 "%~dp0\clang_format.py" %* diff --git a/clang_format.py b/clang_format.py index b7b60a8f7..64f4c6ea4 100755 --- a/clang_format.py +++ b/clang_format.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2014 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. diff --git a/clang_format_merge_driver b/clang_format_merge_driver index 8b7904946..7298c5415 100755 --- a/clang_format_merge_driver +++ b/clang_format_merge_driver @@ -5,4 +5,4 @@ base_dir=$(dirname "$0") -PYTHONDONTWRITEBYTECODE=1 exec python "$base_dir/clang_format_merge_driver.py" "$@" +PYTHONDONTWRITEBYTECODE=1 exec python3 "$base_dir/clang_format_merge_driver.py" "$@" diff --git a/clang_format_merge_driver.bat b/clang_format_merge_driver.bat index 8e614b492..a49ca1a5b 100755 --- a/clang_format_merge_driver.bat +++ b/clang_format_merge_driver.bat @@ -9,4 +9,4 @@ setlocal set PATH=%PATH%;%~dp0 :: Defer control. -python "%~dp0\clang_format_merge_driver.py" %* +python3 "%~dp0\clang_format_merge_driver.py" %* diff --git a/clang_format_merge_driver.py b/clang_format_merge_driver.py index 86e803372..2e5211c41 100755 --- a/clang_format_merge_driver.py +++ b/clang_format_merge_driver.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2016 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. diff --git a/compile_single_file b/compile_single_file index e65816cc1..33c23c69e 100755 --- a/compile_single_file +++ b/compile_single_file @@ -5,4 +5,4 @@ base_dir=$(dirname "$0") -PYTHONDONTWRITEBYTECODE=1 exec python -u "$base_dir/compile_single_file.py" "$@" +PYTHONDONTWRITEBYTECODE=1 exec python3 -u "$base_dir/compile_single_file.py" "$@" diff --git a/compile_single_file.bat b/compile_single_file.bat index 84ff3484f..598f9f221 100644 --- a/compile_single_file.bat +++ b/compile_single_file.bat @@ -8,4 +8,4 @@ setlocal :: standalone, but allow other PATH manipulations to take priority. set PATH=%PATH%;%~dp0 -python -u "%~dp0compile_single_file.py" %* +python3 -u "%~dp0compile_single_file.py" %* diff --git a/compile_single_file.py b/compile_single_file.py index 833e03ef6..bb0a5416d 100644 --- a/compile_single_file.py +++ b/compile_single_file.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017 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. diff --git a/git-runhooks b/git-runhooks index 5bb503e51..df275bf2b 100755 --- a/git-runhooks +++ b/git-runhooks @@ -15,9 +15,9 @@ gclient_spec="solutions=[{'name':'src','url':None,'deps_file':'.DEPS.git'}]" kernel_name=$(uname -s) if [ "${kernel_name:0:5}" = "MINGW" ]; then dir="${0%\\*}" - cmd "/C ${dir}\\python.bat ${dir}\\gclient.py runhooks --spec=$gclient_spec" + cmd "/C ${dir}\\python3.bat ${dir}\\gclient.py runhooks --spec=$gclient_spec" else dir="$(dirname $0)" - PYTHONDONTWRITEBYTECODE=1 exec python "$dir/gclient.py" runhooks --spec="$gclient_spec" + PYTHONDONTWRITEBYTECODE=1 exec python3 "$dir/gclient.py" runhooks --spec="$gclient_spec" fi exit $? diff --git a/testing_support/cipd b/testing_support/cipd index 21519a129..6d2929c93 100755 --- a/testing_support/cipd +++ b/testing_support/cipd @@ -5,4 +5,4 @@ base_dir=$(dirname "$0") -exec python "$base_dir/fake_cipd.py" "$@" +exec python3 "$base_dir/fake_cipd.py" "$@" diff --git a/testing_support/cipd.bat b/testing_support/cipd.bat index a1a941061..f5b6df7dd 100755 --- a/testing_support/cipd.bat +++ b/testing_support/cipd.bat @@ -5,4 +5,4 @@ echo off setlocal :: Defer control. -python "%~dp0fake_cipd.py" %* +python3 "%~dp0fake_cipd.py" %* diff --git a/testing_support/fake_cipd.py b/testing_support/fake_cipd.py index 9bb3cf10b..1dab00663 100644 --- a/testing_support/fake_cipd.py +++ b/testing_support/fake_cipd.py @@ -1,9 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2018 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. import argparse +import io import os import re import shutil @@ -20,8 +21,10 @@ def parse_cipd(root, contents): line = line.strip() match = re.match(CIPD_SUBDIR_RE, line) if match: + print('match') current_subdir = os.path.join(root, *match.group(1).split('/')) elif line and current_subdir: + print('no match') tree.setdefault(current_subdir, []).append(line) return tree @@ -33,15 +36,15 @@ def main(): parser.add_argument('-root') args, _ = parser.parse_known_args() - with open(args.ensure_file) as f: + with io.open(args.ensure_file, 'r', encoding='utf-8') as f: new_content = parse_cipd(args.root, f.readlines()) # Install new packages for path, packages in new_content.items(): if not os.path.exists(path): os.makedirs(path) - with open(os.path.join(path, '_cipd'), 'wb') as f: - f.write('\n'.join(packages).encode('utf-8', 'replace')) + with io.open(os.path.join(path, '_cipd'), 'w', encoding='utf-8') as f: + f.write('\n'.join(packages)) # Save the ensure file that we got shutil.copy(args.ensure_file, os.path.join(args.root, '_cipd')) diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index c4a4da580..ba2441c6a 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be @@ -11,6 +11,7 @@ from __future__ import print_function import atexit import datetime import errno +import io import logging import os import pprint @@ -49,7 +50,8 @@ def read_tree(tree_root): for f in [join(root, f) for f in files if not f.startswith('.')]: filepath = f[len(tree_root) + 1:].replace(os.sep, '/') assert len(filepath), f - tree[filepath] = gclient_utils.FileRead(join(root, f)) + with io.open(join(root, f), encoding='utf-8') as f: + tree[filepath] = f.read() return tree