switch shebangs to python3
This will make `repo upload` execute us using python3 all the time.
We keep the Python 2 logic in place in case we need to rollback.
We can do this now that enough of chromite supports Python 3.
BUG=chromium:1003955
TEST=`repo upload` works with python3
Change-Id: I7d25cf2b9cbbec8f0303ed68b02e1d9144b81b73
Reviewed-on: https://chromium-review.googlesource.com/1875508
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
diff --git a/clang-format.py b/clang-format.py
index 1773dbd..1b1d365 100755
--- a/clang-format.py
+++ b/clang-format.py
@@ -1,5 +1,5 @@
-#!/usr/bin/env python2
-# -*- coding:utf-8 -*-
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -114,7 +114,9 @@
try:
result = cros_build_lib.RunCommand(cmd=cmd,
print_cmd=False,
- redirect_stdout=True)
+ redirect_stdout=True,
+ encoding='utf-8',
+ errors='replace')
except cros_build_lib.RunCommandError as e:
print('clang-format failed:\n' + str(e), file=sys.stderr)
print('\nPlease report this to the clang team.', file=sys.stderr)
diff --git a/pre-upload.py b/pre-upload.py
index 75f3fcd..0b8a055 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@@ -1425,6 +1425,8 @@
cmd_result = cros_build_lib.RunCommand(cmd=cmd,
print_cmd=False,
redirect_stdout=True,
+ encoding='utf-8',
+ errors='replace',
combine_stdout_stderr=True,
error_code_ok=True)
if cmd_result.returncode:
@@ -1452,7 +1454,8 @@
cmd = [os.path.join(hooks_dir, 'checkpatch.pl')] + options + ['-']
cmd_result = cros_build_lib.RunCommand(
cmd=cmd, print_cmd=False, input=_get_patch(commit).encode('utf-8'),
- redirect_stdout=True, combine_stdout_stderr=True, error_code_ok=True)
+ redirect_stdout=True, combine_stdout_stderr=True, error_code_ok=True,
+ encoding='utf-8', errors='replace')
if cmd_result.returncode:
return HookFailure('checkpatch.pl errors/warnings\n\n' + cmd_result.output)
return None
@@ -1622,6 +1625,8 @@
input=os.devnull,
redirect_stdout=True,
combine_stdout_stderr=True,
+ encoding='utf-8',
+ errors='replace',
error_code_ok=True)
if cmd_result.returncode:
stdout = cmd_result.output
diff --git a/pre-upload_unittest.py b/pre-upload_unittest.py
index daee112..26459f2 100755
--- a/pre-upload_unittest.py
+++ b/pre-upload_unittest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be