From 93c4a6a3f70e389b466fbc7a4f1ad2e1df87c93f Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 21 Sep 2016 10:52:53 +1000 Subject: all: Remove 'name' member from mp_obj_module_t struct. One can instead lookup __name__ in the modules dict to get the value. --- py/modstruct.c | 1 - 1 file changed, 1 deletion(-) (limited to 'py/modstruct.c') diff --git a/py/modstruct.c b/py/modstruct.c index be0d0110de..5c07b8102a 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -265,7 +265,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_t const mp_obj_module_t mp_module_ustruct = { .base = { &mp_type_module }, - .name = MP_QSTR_ustruct, .globals = (mp_obj_dict_t*)&mp_module_struct_globals, }; -- cgit v1.2.3 From dffa383b062b0dd788abed0af242b66bde910e6b Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 7 Oct 2016 12:54:14 +1100 Subject: py/modstruct: Remove unreachable code, and add comment about CPy diff. The deleted code is unreachable because calcsize_items guarantees that num_items corresponds to how many items there are in fmt to unpack. --- py/modstruct.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'py/modstruct.c') diff --git a/py/modstruct.c b/py/modstruct.c index 5c07b8102a..88411ff0fc 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -156,9 +156,6 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) { } for (uint i = 0; i < num_items;) { - if (*fmt == '\0') { - break; - } mp_uint_t sz = 1; if (unichar_isdigit(*fmt)) { sz = get_fmt_num(&fmt); @@ -191,6 +188,7 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, byte* end_p, siz for (i = 0; i < n_args;) { mp_uint_t sz = 1; if (*fmt == '\0') { + // more arguments given than used by format string; CPython raises struct.error here break; } if (unichar_isdigit(*fmt)) { -- cgit v1.2.3