From 5eac9d301390c5ff8afdaa95f46e68bb84e20575 Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Tue, 1 Oct 2019 22:17:53 +0000 Subject: [PATCH] depot_tools: Fix bug when running download_from_google on Python 3. Issue caused by utf-8 vs byte mismatch in python 3. Bug: 1009698 Change-Id: I8ab6b129ea9ab18f06f8ff4eb5da3aa018829365 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1832773 Commit-Queue: Edward Lesmes Reviewed-by: Anthony Polito --- download_from_google_storage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index 0fc3c5666..7ea0829a4 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -175,7 +175,7 @@ def enumerate_input(input_filename, directory, recursive, ignore_errors, output, with open(input_filename, 'rb') as f: sha1_match = re.match(b'^([A-Za-z0-9]{40})$', f.read(1024).rstrip()) if sha1_match: - yield (sha1_match.groups(1)[0], output) + yield (sha1_match.groups(1)[0].decode('utf-8'), output) return if not ignore_errors: raise InvalidFileError('No sha1 sum found in %s.' % input_filename) @@ -214,7 +214,10 @@ def enumerate_input(input_filename, directory, recursive, ignore_errors, output, with open(full_path, 'rb') as f: sha1_match = re.match(b'^([A-Za-z0-9]{40})$', f.read(1024).rstrip()) if sha1_match: - yield (sha1_match.groups(1)[0], full_path.replace('.sha1', '')) + yield ( + sha1_match.groups(1)[0].decode('utf-8'), + full_path.replace('.sha1', '') + ) else: if not ignore_errors: raise InvalidFileError('No sha1 sum found in %s.' % filename)