From e53fb1bf031a53ad23a45846addf14e25cebb97d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 14 May 2016 15:47:08 +0300 Subject: [PATCH] py/modstruct: Raise ValueError on unsupported format char. --- py/modstruct.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py/modstruct.c b/py/modstruct.c index cd32097388..eabc951aef 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -120,8 +120,9 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { if (sz == 0) { sz = (mp_uint_t)mp_binary_get_size(fmt_type, *fmt, &align); } - // TODO - assert(sz != (mp_uint_t)-1); + if (sz == 0) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "unsupported format")); + } // Apply alignment size = (size + align - 1) & ~(align - 1); size += sz;