summaryrefslogtreecommitdiff
path: root/tests/basics/struct2.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-01-17 22:50:20 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-01-17 22:53:06 +0300
commitaf9046193148084f008501434e4c9f49fedc053f (patch)
tree7a05a10f74c645a5154f877c14eebbae25bd45f3 /tests/basics/struct2.py
parent5e80c53c115e8b45df598ffdbc45dfdd543be8ac (diff)
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.
Diffstat (limited to 'tests/basics/struct2.py')
-rw-r--r--tests/basics/struct2.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/basics/struct2.py b/tests/basics/struct2.py
index 6dd963260..e3f8bbebf 100644
--- a/tests/basics/struct2.py
+++ b/tests/basics/struct2.py
@@ -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: