Fix py version of struct too.

This commit is contained in:
Scott Shawcroft 2021-04-19 14:58:40 -07:00
parent 390398371d
commit 6620ac8bec
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
1 changed files with 4 additions and 2 deletions

View File

@ -214,9 +214,11 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c
p += cnt;
} else {
while (cnt--) {
mp_binary_set_val(fmt_type, *fmt, args[i], &p);
// Pad bytes don't have a corresponding argument.
if (*fmt != 'x') {
if (*fmt == 'x') {
mp_binary_set_val(fmt_type, *fmt, MP_OBJ_NEW_SMALL_INT(0), &p);
} else {
mp_binary_set_val(fmt_type, *fmt, args[i], &p);
i++;
}
}