py: Fix handling of negative numbers in struct.pack of q/Q.
This commit is contained in:
@@ -291,6 +291,10 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
|
||||
#endif
|
||||
{
|
||||
val = mp_obj_get_int(val_in);
|
||||
// sign extend if needed
|
||||
if (BYTES_PER_WORD < 8 && size > sizeof(val) && is_signed(val_type) && (mp_int_t)val < 0) {
|
||||
memset(p + sizeof(val), 0xff, size - sizeof(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user