From 4de5deacd4a7cb46637a3d446b9c0dc258be1159 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Wed, 23 Mar 2022 21:15:14 +0000 Subject: [PATCH] Explicitly run everything with python3 R=aravindvasudev@google.com, gavinmak@google.com Change-Id: Iaa5e960c6226dea3a0814c7cb778d952eafb1502 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3525960 Reviewed-by: Gavin Mak Reviewed-by: Aravind Vasudevan Commit-Queue: Josip Sokcevic --- detect_host_arch.py | 2 +- fetch.py | 2 +- gclient-new-workdir.py | 2 +- git_cache.py | 2 +- git_cl.py | 2 +- git_drover.py | 2 +- git_find_releases.py | 2 +- git_footers.py | 2 +- git_freezer.py | 2 +- git_hyper_blame.py | 2 +- git_map.py | 2 +- git_map_branches.py | 2 +- git_mark_merge_base.py | 2 +- git_nav_downstream.py | 2 +- git_new_branch.py | 2 +- git_rebase_update.py | 2 +- git_rename_branch.py | 2 +- git_reparent_branch.py | 2 +- git_retry.py | 6 ++--- git_squash_branch.py | 2 +- git_upstream_diff.py | 2 +- metrics.py | 4 +-- metrics_utils.py | 2 +- presubmit_canned_checks_test.py | 2 +- presubmit_support.py | 10 +++++--- pylint_main.py | 2 +- rdb_wrapper.py | 2 +- repo_launcher | 2 +- roll_dep.py | 2 +- setup_color.py | 2 +- split_cl.py | 2 +- testing_support/subprocess2_test_script.py | 2 +- upload_to_google_storage.py | 28 ++++++++++++--------- watchlists.py | 2 +- weekly | 2 +- win_toolchain/get_toolchain_if_necessary.py | 2 +- win_toolchain/package_from_installed.py | 2 +- wtf | 6 ++--- 38 files changed, 63 insertions(+), 57 deletions(-) diff --git a/detect_host_arch.py b/detect_host_arch.py index cf4bfec7d8..0843d642a5 100755 --- a/detect_host_arch.py +++ b/detect_host_arch.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/fetch.py b/fetch.py index f19f103bd7..45e34a138a 100755 --- a/fetch.py +++ b/fetch.py @@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright (c) 2013 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/gclient-new-workdir.py b/gclient-new-workdir.py index e9eee62b1a..108990e379 100755 --- a/gclient-new-workdir.py +++ b/gclient-new-workdir.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2013 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_cache.py b/git_cache.py index d612c25b83..03f7413fd1 100755 --- a/git_cache.py +++ b/git_cache.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/git_cl.py b/git_cl.py index 715b9822d9..a3a9481197 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright (c) 2013 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_drover.py b/git_drover.py index 49912196c4..524d967b70 100755 --- a/git_drover.py +++ b/git_drover.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 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/git_find_releases.py b/git_find_releases.py index 8da917af6d..770cc01d4b 100755 --- a/git_find_releases.py +++ b/git_find_releases.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 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/git_footers.py b/git_footers.py index a096b6f5c0..88149c9828 100755 --- a/git_footers.py +++ b/git_footers.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/git_freezer.py b/git_freezer.py index ec277f5577..c0f73c367f 100755 --- a/git_freezer.py +++ b/git_freezer.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/git_hyper_blame.py b/git_hyper_blame.py index 6a8dae88aa..1b63a3b202 100755 --- a/git_hyper_blame.py +++ b/git_hyper_blame.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/git_map.py b/git_map.py index d7514a469e..10b321bfbb 100755 --- a/git_map.py +++ b/git_map.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/git_map_branches.py b/git_map_branches.py index ca5f95134d..da63d7af72 100755 --- a/git_map_branches.py +++ b/git_map_branches.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/git_mark_merge_base.py b/git_mark_merge_base.py index c6b3181020..35ae5eebb0 100755 --- a/git_mark_merge_base.py +++ b/git_mark_merge_base.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/git_nav_downstream.py b/git_nav_downstream.py index 85f9855dc2..a77d9a2a7b 100755 --- a/git_nav_downstream.py +++ b/git_nav_downstream.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/git_new_branch.py b/git_new_branch.py index 3a07c27253..bdf8bcf2ff 100755 --- a/git_new_branch.py +++ b/git_new_branch.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/git_rebase_update.py b/git_rebase_update.py index 716111e209..5c88474408 100755 --- a/git_rebase_update.py +++ b/git_rebase_update.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/git_rename_branch.py b/git_rename_branch.py index d40b606812..95094e85ea 100755 --- a/git_rename_branch.py +++ b/git_rename_branch.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/git_reparent_branch.py b/git_reparent_branch.py index c1f8f2a09d..5e686d1334 100755 --- a/git_reparent_branch.py +++ b/git_reparent_branch.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/git_retry.py b/git_retry.py index 0dc90ee847..e67ef1e45b 100755 --- a/git_retry.py +++ b/git_retry.py @@ -1,10 +1,10 @@ -#!/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. -"""Generic retry wrapper for Git operations. +"""Generic retry wrapper for Git operations. This is largely DEPRECATED in favor of the Infra Git wrapper: https://chromium.googlesource.com/infra/infra/+/HEAD/go/src/infra/tools/git @@ -95,7 +95,7 @@ class GitRetry(object): def __call__(self, *args): returncode = 0 - for i in xrange(self.retry_count): + for i in range(self.retry_count): # If the previous run failed and a delay is configured, delay before the # next run. delay = self.computeDelay(i) diff --git a/git_squash_branch.py b/git_squash_branch.py index f0534ca3cc..9b9485ab07 100755 --- a/git_squash_branch.py +++ b/git_squash_branch.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/git_upstream_diff.py b/git_upstream_diff.py index c21828fe7c..f1e712ea88 100755 --- a/git_upstream_diff.py +++ b/git_upstream_diff.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/metrics.py b/metrics.py index 5e3a9356a0..c5b86b66be 100644 --- a/metrics.py +++ b/metrics.py @@ -1,4 +1,4 @@ -#!/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. @@ -62,7 +62,7 @@ class _Config(object): self._initialized = True return - # We are running on a bot. Ignore config and collect metrics. + # We are running on a bot. Ignore config and collect metrics. if metrics_utils.REPORT_BUILD: self._config = { 'is-googler': True, diff --git a/metrics_utils.py b/metrics_utils.py index 96982a9d88..e1757bc6b8 100644 --- a/metrics_utils.py +++ b/metrics_utils.py @@ -1,4 +1,4 @@ -#!/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. diff --git a/presubmit_canned_checks_test.py b/presubmit_canned_checks_test.py index 163a8cd57c..0903f5b2dc 100644 --- a/presubmit_canned_checks_test.py +++ b/presubmit_canned_checks_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2021 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/presubmit_support.py b/presubmit_support.py index 032320e035..950cb1bbe8 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # 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,9 +734,11 @@ class InputApi(object): ' is deprecated and ignored' % str(include_deletes), category=DeprecationWarning, stacklevel=2) - return list(filter( - lambda x: x.IsTestableFile(), - self.AffectedFiles(include_deletes=False, **kwargs))) + # pylint: disable=consider-using-generator + return [ + x for x in self.AffectedFiles(include_deletes=False, **kwargs) + if x.IsTestableFile() + ] def AffectedTextFiles(self, include_deletes=None): """An alias to AffectedTestableFiles for backwards compatibility.""" diff --git a/pylint_main.py b/pylint_main.py index d03021ddbe..25cb40b6a3 100755 --- a/pylint_main.py +++ b/pylint_main.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2019 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/rdb_wrapper.py b/rdb_wrapper.py index 66dd720ee1..35ce8d5d34 100644 --- a/rdb_wrapper.py +++ b/rdb_wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright (c) 2020 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/repo_launcher b/repo_launcher index eb2b576cc1..7b6673a736 100755 --- a/repo_launcher +++ b/repo_launcher @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding:utf-8 -*- # # Copyright (C) 2008 The Android Open Source Project diff --git a/roll_dep.py b/roll_dep.py index ace0399a1f..be8b6b09b4 100755 --- a/roll_dep.py +++ b/roll_dep.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 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/setup_color.py b/setup_color.py index 03297f825e..8fd669012f 100644 --- a/setup_color.py +++ b/setup_color.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 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/split_cl.py b/split_cl.py index f742360b3f..420c8ad6e7 100644 --- a/split_cl.py +++ b/split_cl.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/testing_support/subprocess2_test_script.py b/testing_support/subprocess2_test_script.py index 5fe27c63c3..f55e198af5 100644 --- a/testing_support/subprocess2_test_script.py +++ b/testing_support/subprocess2_test_script.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2019 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/upload_to_google_storage.py b/upload_to_google_storage.py index 0d8b288439..2933cc2cfb 100755 --- a/upload_to_google_storage.py +++ b/upload_to_google_storage.py @@ -233,18 +233,22 @@ def create_archives(dirs): def validate_archive_dirs(dirs): - # We don't allow .. in paths in our archives. - if any(map(lambda x: '..' in x, dirs)): - return False - # We only allow dirs. - if any(map(lambda x: not os.path.isdir(x), dirs)): - return False - # We don't allow sym links in our archives. - if any(map(os.path.islink, dirs)): - return False - # We required that the subdirectories we are archiving are all just below - # cwd. - return not any(map(lambda x: x not in next(os.walk('.'))[1], dirs)) + for d in dirs: + # We don't allow .. in paths in our archives. + if d == '..': + return False + # We only allow dirs. + if not os.path.isdir(d): + return False + # We don't allow sym links in our archives. + if os.path.islink(d): + return False + # We required that the subdirectories we are archiving are all just below + # cwd. + if d not in next(os.walk('.'))[1]: + return False + + return True def main(): diff --git a/watchlists.py b/watchlists.py index 4ff270f49b..fca78a9238 100755 --- a/watchlists.py +++ b/watchlists.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2011 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/weekly b/weekly index 6f9bd1d028..853522597d 100755 --- a/weekly +++ b/weekly @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2010 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/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index 328f79ba6c..5f2ada6ed8 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2013 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/win_toolchain/package_from_installed.py b/win_toolchain/package_from_installed.py index 92a3692a9d..ad87821b73 100644 --- a/win_toolchain/package_from_installed.py +++ b/win_toolchain/package_from_installed.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/wtf b/wtf index 5346eb1fd2..da4095d9cd 100755 --- a/wtf +++ b/wtf @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2010 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. @@ -71,8 +71,8 @@ def main(): # We want to use the full path for testing, but we want to use the relative # path for display. - fulldirs = map(lambda(p): os.path.normpath(os.path.join(root, p)), raw) - reldirs = map(lambda(p): re.sub('^' + base, '.', p), raw) + fulldirs = [os.path.normpath(os.path.join(root, p)) for p in raw] + reldirs = [re.sub('^' + base, '.', p) for p in raw] for full_path, relative_path in zip(fulldirs, reldirs): show_dir(full_path, relative_path, color)