summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-07 12:54:14 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-07 12:54:14 +1100
commitdffa383b062b0dd788abed0af242b66bde910e6b (patch)
tree7bfd4dc8d361277b4ba90362bdfe3fdb9dd674b2
parent9fdba0e09c7522130d6609362973bdf5feda1a2e (diff)
downloadmicropython-dffa383b062b0dd788abed0af242b66bde910e6b.tar.gz
micropython-dffa383b062b0dd788abed0af242b66bde910e6b.zip
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.
-rw-r--r--py/modstruct.c4
1 files changed, 1 insertions, 3 deletions
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)) {