From 3e9eda17343c6a92a6af9f8b0ce9b7868951fa68 Mon Sep 17 00:00:00 2001 From: Dirk Pranke Date: Wed, 19 May 2021 23:57:48 +0000 Subject: [PATCH] Revert "Try again to fix UnicodeDecodeError in CheckAuthorizedAuthor." This reverts commit dd0076703b55ea14f15666c62759ea242906e4b7. Reason for revert: Change wasn't correct. Original change's description: > Try again to fix UnicodeDecodeError in CheckAuthorizedAuthor. > > This will attempt to do so in a Python2-compatible way. > > Bug: 1210746 > Change-Id: I09edc21a5c47106803c0ac5ca449e0f8732efb24 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2906501 > Auto-Submit: Dirk Pranke > Reviewed-by: Edward Lesmes > Commit-Queue: Edward Lesmes Bug: 1210746 Change-Id: Ia101d73857abe3d65ba48e05e7a0bc98efb2fd37 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2908152 Bot-Commit: Rubber Stamper Commit-Queue: Dirk Pranke --- presubmit_canned_checks.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 243912b59..0b9747eca 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -126,14 +126,10 @@ def CheckAuthorizedAuthor(input_api, output_api, bot_allowlist=None): authors_path = input_api.os_path.join( input_api.PresubmitLocalPath(), 'AUTHORS') - author_re = input_api.re.compile(r'[^#]+\s+\<(.+?)\>\s*$') - valid_authors = [] - with open(authors_path, 'rb') as fp: - for line in fp: - m = author_re.match(line.decode('utf8')) - if m: - valid_authors.append(m.group(1)).lower() - + valid_authors = ( + input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line) + for line in open(authors_path)) + valid_authors = [item.group(1).lower() for item in valid_authors if item] if not any(input_api.fnmatch.fnmatch(author.lower(), valid) for valid in valid_authors): input_api.logging.info('Valid authors are %s', ', '.join(valid_authors))