ANDROID: build: Decoding byte strings properly

Currently, build_with_bazel.py will break when run with Python 3 due
to differences in the way Python 2 and 3 encode string types.

Explicitly decode command outputs to utf-8 strings which works
properly for both Python versions.

Change-Id: I921bd591ce16b5b91c76a6bb2a5d0e8626c29c19
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
This commit is contained in:
John Moon 2022-12-20 17:07:17 -08:00
parent a4d898e2ae
commit 139e408949

View File

@ -128,7 +128,7 @@ class BazelBuilder:
cmdline, cwd=self.workspace, stdout=subprocess.PIPE
)
self.process_list.append(query_cmd)
target_list = query_cmd.stdout.read().splitlines()
target_list = [l.decode("utf-8") for l in query_cmd.stdout.read().splitlines()]
except Exception as e:
logging.error(e)
sys.exit(1)
@ -172,7 +172,7 @@ class BazelBuilder:
cmdline, cwd=self.workspace, stdout=subprocess.PIPE
)
self.process_list.append(query_cmd)
toolchain = query_cmd.stdout.read().strip()
toolchain = query_cmd.stdout.read().strip().decode("utf-8")
except Exception as e:
logging.error(e)
sys.exit(1)