diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-07-05 22:37:32 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-07-05 22:44:14 +0300 |
commit | 7e66b859b2cfbd09bbe0d4307868b0d1a0ad818f (patch) | |
tree | ba709a166a1c120b399ade9b1444678f243f3dda /py/modstruct.c | |
parent | aaf7c5b35e38109ce74f3ef71f4787d2d9c7645e (diff) | |
download | micropython-7e66b859b2cfbd09bbe0d4307868b0d1a0ad818f.tar.gz micropython-7e66b859b2cfbd09bbe0d4307868b0d1a0ad818f.zip |
modstruct: Raise NotImplementedError for unsupported repeat specification.
Diffstat (limited to 'py/modstruct.c')
-rw-r--r-- | py/modstruct.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/py/modstruct.c b/py/modstruct.c index 0c4af707d6..1ba974d55d 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -28,6 +28,7 @@ #include <assert.h> #include <string.h> +#include "py/runtime.h" #include "py/builtin.h" #include "py/objtuple.h" #include "py/binary.h" @@ -104,7 +105,9 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { } if (cnt > 1) { // TODO: count spec support only for string len - assert(*fmt == 's'); + if (*fmt != 's') { + mp_not_implemented("count>1"); + } } mp_uint_t sz; @@ -140,7 +143,9 @@ STATIC mp_obj_t struct_unpack(mp_obj_t fmt_in, mp_obj_t data_in) { } if (sz > 1) { // TODO: size spec support only for string len - assert(*fmt == 's'); + if (*fmt != 's') { + mp_not_implemented("count>1"); + } } mp_obj_t item; if (*fmt == 's') { @@ -173,7 +178,9 @@ STATIC mp_obj_t struct_pack(mp_uint_t n_args, const mp_obj_t *args) { } if (sz > 1) { // TODO: size spec support only for string len - assert(*fmt == 's'); + if (*fmt != 's') { + mp_not_implemented("count>1"); + } } if (*fmt == 's') { |