Skip to content
Snippets Groups Projects
Commit 7e66b859 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

modstruct: Raise NotImplementedError for unsupported repeat specification.

parent aaf7c5b3
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "py/runtime.h"
#include "py/builtin.h" #include "py/builtin.h"
#include "py/objtuple.h" #include "py/objtuple.h"
#include "py/binary.h" #include "py/binary.h"
...@@ -104,7 +105,9 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) { ...@@ -104,7 +105,9 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
} }
if (cnt > 1) { if (cnt > 1) {
// TODO: count spec support only for string len // TODO: count spec support only for string len
assert(*fmt == 's'); if (*fmt != 's') {
mp_not_implemented("count>1");
}
} }
mp_uint_t sz; mp_uint_t sz;
...@@ -140,7 +143,9 @@ STATIC mp_obj_t struct_unpack(mp_obj_t fmt_in, mp_obj_t data_in) { ...@@ -140,7 +143,9 @@ STATIC mp_obj_t struct_unpack(mp_obj_t fmt_in, mp_obj_t data_in) {
} }
if (sz > 1) { if (sz > 1) {
// TODO: size spec support only for string len // TODO: size spec support only for string len
assert(*fmt == 's'); if (*fmt != 's') {
mp_not_implemented("count>1");
}
} }
mp_obj_t item; mp_obj_t item;
if (*fmt == 's') { if (*fmt == 's') {
...@@ -173,7 +178,9 @@ STATIC mp_obj_t struct_pack(mp_uint_t n_args, const mp_obj_t *args) { ...@@ -173,7 +178,9 @@ STATIC mp_obj_t struct_pack(mp_uint_t n_args, const mp_obj_t *args) {
} }
if (sz > 1) { if (sz > 1) {
// TODO: size spec support only for string len // TODO: size spec support only for string len
assert(*fmt == 's'); if (*fmt != 's') {
mp_not_implemented("count>1");
}
} }
if (*fmt == 's') { if (*fmt == 's') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment