From 80938839c1513370d50d3aa6c9fc66a8b3ca1162 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 17 May 2022 19:45:06 +1000 Subject: [PATCH] tests/extmod: Use bytearray instead of bytes for uctypes test. Because the test modifies the (now) bytearray object, and if it's a bytes object it's not guaranteed that it can be modified, or that this constant object isn't used elsewhere. Signed-off-by: Damien George --- tests/extmod/uctypes_32bit_intbig.py | 4 ++-- tests/extmod/uctypes_32bit_intbig.py.exp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/extmod/uctypes_32bit_intbig.py b/tests/extmod/uctypes_32bit_intbig.py index eed36e8774..27d33817cf 100644 --- a/tests/extmod/uctypes_32bit_intbig.py +++ b/tests/extmod/uctypes_32bit_intbig.py @@ -6,7 +6,7 @@ except ImportError: print("SKIP") raise SystemExit -buf = b"12345678abcd" +buf = bytearray(b"12345678abcd") struct = uctypes.struct( uctypes.addressof(buf), {"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, @@ -30,7 +30,7 @@ print(buf) print("=") -buf = b"12345678abcd" +buf = bytearray(b"12345678abcd") struct = uctypes.struct( uctypes.addressof(buf), {"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, diff --git a/tests/extmod/uctypes_32bit_intbig.py.exp b/tests/extmod/uctypes_32bit_intbig.py.exp index d1fc1fe350..1b16ddbc32 100644 --- a/tests/extmod/uctypes_32bit_intbig.py.exp +++ b/tests/extmod/uctypes_32bit_intbig.py.exp @@ -1,11 +1,11 @@ -b'\xff\xff\xff\x7f5678abcd' -b'\x00\x00\x00\x805678abcd' -b'\x03\x02\x01\xff5678abcd' -b'\x03\x02\x01\xff\x00\x00\x00\x80\x00\x00\x00\x00' -b'\x03\x02\x01\xff\x00\x00\x00\x00\x01\x00\x00\x00' +bytearray(b'\xff\xff\xff\x7f5678abcd') +bytearray(b'\x00\x00\x00\x805678abcd') +bytearray(b'\x03\x02\x01\xff5678abcd') +bytearray(b'\x03\x02\x01\xff\x00\x00\x00\x80\x00\x00\x00\x00') +bytearray(b'\x03\x02\x01\xff\x00\x00\x00\x00\x01\x00\x00\x00') = -b'\x7f\xff\xff\xff5678abcd' -b'\x80\x00\x00\x005678abcd' -b'\xff\x01\x02\x035678abcd' -b'\xff\x01\x02\x03\x00\x00\x00\x00\x80\x00\x00\x00' -b'\xff\x01\x02\x03\x00\x00\x00\x01\x00\x00\x00\x00' +bytearray(b'\x7f\xff\xff\xff5678abcd') +bytearray(b'\x80\x00\x00\x005678abcd') +bytearray(b'\xff\x01\x02\x035678abcd') +bytearray(b'\xff\x01\x02\x03\x00\x00\x00\x00\x80\x00\x00\x00') +bytearray(b'\xff\x01\x02\x03\x00\x00\x00\x01\x00\x00\x00\x00')