Fix 'expected str instance, bytes found' error when compute patches

When building an incremental OTA package, if the compress_target=True
parameter is passed in when calculating a block, an exception will occur
in the subsequent join operation.

The reason is that Python 3 no longer allows str type join bytes type.

Bug: None
Test: Build Incremental OTA package

Change-Id: I6d556f9905b7ab75b70d3785334d71d5a6e5479b
Signed-off-by: luoqiangwei1 <luoqiangwei1@xiaomi.com>
This commit is contained in:
luoqiangwei1 2022-11-11 00:05:56 +08:00
parent a2faaa8c45
commit 3e3456bb72

View file

@ -1171,7 +1171,7 @@ class BlockImageDiff(object):
try:
# Compresses with the default level
compress_obj = zlib.compressobj(6, zlib.DEFLATED, -zlib.MAX_WBITS)
compressed_data = (compress_obj.compress("".join(tgt_data))
compressed_data = (compress_obj.compress(b"".join(tgt_data))
+ compress_obj.flush())
compressed_size = len(compressed_data)
except zlib.error as e: