diff options
author | Damien George <damien.p.george@gmail.com> | 2017-09-01 10:10:51 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-09-01 10:10:51 +1000 |
commit | 793d826d9df67c3f544505beda63ca36d8dfa1c4 (patch) | |
tree | 7d5fe63db397e3fc7deec311b1f4b268c0d117a5 /tests/basics/struct_micropython.py | |
parent | b349479a49aab440b2f38fc6e45b3df4bf7a1aa7 (diff) |
py/modstruct: In struct.pack, stop converting if there are no args left.
This patch makes a repeat counter behave the same as repeating the
typecode, when there are not enough args. For example:
struct.pack('2I', 1) now behave the same as struct.pack('II', 1).
Diffstat (limited to 'tests/basics/struct_micropython.py')
-rw-r--r-- | tests/basics/struct_micropython.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/basics/struct_micropython.py b/tests/basics/struct_micropython.py index 4b9dfe137..f203a4666 100644 --- a/tests/basics/struct_micropython.py +++ b/tests/basics/struct_micropython.py @@ -18,6 +18,9 @@ s = struct.pack("<O", o) o2 = struct.unpack("<O", s) print(o is o2[0]) +# pack can accept less arguments than required for the format spec +print(struct.pack('<2I', 1)) + # pack and unpack pointer to a string # This requires uctypes to get the address of the string and instead of # putting this in a dedicated test that can be skipped we simply pass |