From 64e45950de379602b41b078982ed135f7a3ee492 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Mon, 3 Jun 2019 13:39:21 +0300 Subject: [PATCH] Make the script portable to both pythons Make the script work for python3 and for python2 --- tests/scripts/mbedtls_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py index 62c229631..b7b9dc063 100755 --- a/tests/scripts/mbedtls_test.py +++ b/tests/scripts/mbedtls_test.py @@ -270,7 +270,7 @@ class MbedTlsTest(BaseHostTest): data_bytes += b'S' self.align_32bit(data_bytes) data_bytes += self.int32_to_big_endian_bytes(i) - data_bytes += bytes(param, 'ascii') + data_bytes += bytearray(param, encoding='ascii') data_bytes += b'\0' # Null terminate elif typ == 'hex': binary_data = self.hex_str_bytes(param) @@ -309,7 +309,7 @@ class MbedTlsTest(BaseHostTest): param_bytes, length = self.test_vector_to_bytes(function_id, dependencies, args) - self.send_kv(length.hex(), param_bytes.hex()) + self.send_kv(''.join('{:02x}'.format(x) for x in length), ''.join('{:02x}'.format(x) for x in param_bytes)) @staticmethod def get_result(value):