@@ -130,12 +130,12 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
130130 return mp_obj_new_int (((long * )p )[index ]);
131131 case 'L' :
132132 return mp_obj_new_int_from_uint (((unsigned long * )p )[index ]);
133- #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
133+ #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
134134 case 'q' :
135- case 'Q' :
136- // TODO: Explode API more to cover signedness
137135 return mp_obj_new_int_from_ll (((long long * )p )[index ]);
138- #endif
136+ case 'Q' :
137+ return mp_obj_new_int_from_ull (((unsigned long long * )p )[index ]);
138+ #endif
139139#if MICROPY_PY_BUILTINS_FLOAT
140140 case 'f' :
141141 return mp_obj_new_float (((float * )p )[index ]);
@@ -316,6 +316,13 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
316316 ((mp_obj_t * )p )[index ] = val_in ;
317317 break ;
318318 default :
319+ #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
320+ if ((typecode | 0x20 ) == 'q' && MP_OBJ_IS_TYPE (val_in , & mp_type_int )) {
321+ mp_obj_int_to_bytes_impl (val_in , MP_ENDIANNESS_BIG ,
322+ sizeof (long long ), (byte * )& ((long long * )p )[index ]);
323+ return ;
324+ }
325+ #endif
319326 mp_binary_set_val_array_from_int (typecode , p , index , mp_obj_get_int (val_in ));
320327 }
321328}
@@ -347,13 +354,13 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
347354 case 'L' :
348355 ((unsigned long * )p )[index ] = val ;
349356 break ;
350- #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
357+ #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
351358 case 'q' :
352- case 'Q' :
353- assert (0 );
354359 ((long long * )p )[index ] = val ;
360+ case 'Q' :
361+ ((unsigned long long * )p )[index ] = val ;
355362 break ;
356- #endif
363+ #endif
357364#if MICROPY_PY_BUILTINS_FLOAT
358365 case 'f' :
359366 ((float * )p )[index ] = val ;
0 commit comments