Skip to content

Commit e53fb1b

Browse files
committed
py/modstruct: Raise ValueError on unsupported format char.
1 parent 2ae6697 commit e53fb1b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

py/modstruct.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
120120
if (sz == 0) {
121121
sz = (mp_uint_t)mp_binary_get_size(fmt_type, *fmt, &align);
122122
}
123-
// TODO
124-
assert(sz != (mp_uint_t)-1);
123+
if (sz == 0) {
124+
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "unsupported format"));
125+
}
125126
// Apply alignment
126127
size = (size + align - 1) & ~(align - 1);
127128
size += sz;

0 commit comments

Comments
 (0)