QUERY · ISSUE
struct.pack doesn't check for value bounds
py-core
Setup: MicroPython v1.11-555-g80df377e9 on 2019-11-04; PYBv1.1 with STM32F405RG
struct.pack('B', 256) # returns b'\x00'
CPython errors out with struct.error: ubyte format requires 0 <= number <= 255
CANDIDATE · ISSUE
feature regression: struct packing zero length throws exception
Python3.5
>>> import struct
>>> struct.pack("0s", bytearray(0))
b''
Micropython
>>> import struct
>>> struct.pack("0s", bytearray(0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unsupported format