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.
This commit is contained in:
Paul Sokolovsky
2017-01-17 22:50:20 +03:00
parent 5e80c53c11
commit af90461931
4 changed files with 17 additions and 7 deletions

View File

@@ -113,9 +113,6 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
} else {
mp_uint_t align;
size_t sz = mp_binary_get_size(fmt_type, *fmt, &align);
if (sz == 0) {
mp_raise_ValueError("unsupported format");
}
while (cnt--) {
// Apply alignment
size = (size + align - 1) & ~(align - 1);