Skip to content

Commit dffa383

Browse files
committed
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.
1 parent 9fdba0e commit dffa383

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

py/modstruct.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
156156
}
157157

158158
for (uint i = 0; i < num_items;) {
159-
if (*fmt == '\0') {
160-
break;
161-
}
162159
mp_uint_t sz = 1;
163160
if (unichar_isdigit(*fmt)) {
164161
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
191188
for (i = 0; i < n_args;) {
192189
mp_uint_t sz = 1;
193190
if (*fmt == '\0') {
191+
// more arguments given than used by format string; CPython raises struct.error here
194192
break;
195193
}
196194
if (unichar_isdigit(*fmt)) {

0 commit comments

Comments
 (0)