py/binary: mp_binary_get_size: Raise error on unsupported typecodes.
Previouly, we had errors checked in callers, which led to duplicate code or missing checks in some places.
This commit is contained in:
@@ -26,7 +26,17 @@ print(struct.calcsize('0s1s0H2H'))
|
||||
print(struct.unpack('<0s1s0H2H', b'01234'))
|
||||
print(struct.pack('<0s1s0H2H', b'abc', b'abc', 258, 515))
|
||||
|
||||
# check that zero of an unknown type raises an exception
|
||||
# check that unknown types raise an exception
|
||||
try:
|
||||
struct.unpack('z', b'1')
|
||||
except:
|
||||
print('Exception')
|
||||
|
||||
try:
|
||||
struct.pack('z', (b'1',))
|
||||
except:
|
||||
print('Exception')
|
||||
|
||||
try:
|
||||
struct.calcsize('0z')
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user