Commit 057ab2b3 authored by Mike Frysinger's avatar Mike Frysinger Committed by Commit Bot

grit: change brotli compression entirely to bytes

The brotli logic was mostly using bytes already, but a few places
were still mixing in strings.  Change them over to bytes so the
tests pass on Python 3.

Bug: 983071
Test: `./grit/test_suite_all.py` passes
Change-Id: I23ed796b7f3483de001a77e548c0d786b53dadf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1756243
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687411}
parent 8dc3acc9
......@@ -20,4 +20,4 @@ FAKE_BIDI = 'fake-bidi'
# Magic number added to the header of resources brotli compressed by grit. Used
# to easily identify resources as being brotli compressed. See
# ui/base/resource/resource_bundle.h for decompression usage.
BROTLI_CONST = '\x1e\x9b'
\ No newline at end of file
BROTLI_CONST = b'\x1e\x9b'
......@@ -631,7 +631,7 @@ class Node(object):
# The length of the uncompressed data is also appended to the start,
# truncated to 6 bytes, little-endian. size_bytes is 8 bytes,
# need to truncate further to 6.
formatter = '%ds %dx %ds' % (6, 2, len(size_bytes) - 8)
formatter = b'%ds %dx %ds' % (6, 2, len(size_bytes) - 8)
return (constants.BROTLI_CONST +
b''.join(struct.unpack(formatter, size_bytes)) +
data)
......
......@@ -162,7 +162,7 @@ class StructureUnittest(unittest.TestCase):
uncompress_size += struct.unpack('<h', compressed[6:8])[0] << 4*8
self.assertEqual(actual_size, uncompress_size)
self.assertEqual('This has been mock compressed!', compressed[8:])
self.assertEqual(b'This has been mock compressed!', compressed[8:])
def testNotCompressed(self):
test_data_root = util.PathFromRoot('grit/testdata')
......
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