ta_bin_to_c.py: mark as python3 script
This commit marks the script as a python3 script and update
hex string conversion accordingly.
Moving to python3 requires a change in hex string conversion.
It causes by `zlib.compress()` behaving differently in python2
and python3. It returns a string in python2, and it returns
a bytes object in python3.
With python3 `zlib.compress()` behavior, we can use hex() to
convert bytes[i] of type int into a hex string.
Signed-off-by: Pipat Methavanitpong <pipat.methavanitpong@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
diff --git a/scripts/ta_bin_to_c.py b/scripts/ta_bin_to_c.py
index 1496f81..52a68e4 100755
--- a/scripts/ta_bin_to_c.py
+++ b/scripts/ta_bin_to_c.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2017, Linaro Limited
@@ -79,7 +79,7 @@
while i < size:
if i % 8 == 0:
f.write('\t\t')
- f.write('0x' + '{:02x}'.format(ord(bytes[i])) + ',')
+ f.write(hex(bytes[i]) + ',')
i = i + 1
if i % 8 == 0 or i == size:
f.write('\n')