Commit 5eac9d30 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

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 <ehmaldonado@chromium.org>
Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
parent 451e8bab
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment