From be6d8be91e133e98117025062df0e63aaf87efd2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 5 Dec 2014 23:13:52 +0000 Subject: py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack. mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998. --- tests/basics/struct1.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py index c3049c55d..cebffc142 100644 --- a/tests/basics/struct1.py +++ b/tests/basics/struct1.py @@ -25,3 +25,15 @@ print(struct.pack("<6sH", b"foo", 10000)) s = struct.pack("BHBI", 10, 100, 200, 300) v = struct.unpack("BHBI", s) print(v == (10, 100, 200, 300)) + +# check maximum pack on 32-bit machine +print(struct.pack("