Skip to content

Commit 6cfa61a

Browse files
committed
py/binary: Handle storing big-ints to all arrays types.
Prior to this patch only 'q' and 'Q' type arrays could store big-int values. With this patch any big int that is stored to an array is handled by the big-int implementation, regardless of the typecode of the array. This allows arrays to work with all type sizes on all architectures.
1 parent 4a4490f commit 6cfa61a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

py/binary.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,10 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
327327
break;
328328
default:
329329
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
330-
if ((typecode | 0x20) == 'q' && MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
330+
if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
331+
size_t size = mp_binary_get_size('@', typecode, NULL);
331332
mp_obj_int_to_bytes_impl(val_in, MP_ENDIANNESS_BIG,
332-
sizeof(long long), (byte*)&((long long*)p)[index]);
333+
size, (uint8_t*)p + index * size);
333334
return;
334335
}
335336
#endif

0 commit comments

Comments
 (0)