Browse Source

unix/modos: Support larger integer range in uos.stat fields.

On 32-bit builds these stat fields will overflow a small-int, so use
mp_obj_new_int_from_uint to construct the int object.

Signed-off-by: Damien George <damien@micropython.org>
pull/6390/head
Damien George 4 years ago
parent
commit
0385b21597
  1. 16
      ports/unix/modos.c

16
ports/unix/modos.c

@ -58,15 +58,15 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
t->items[0] = MP_OBJ_NEW_SMALL_INT(sb.st_mode);
t->items[1] = MP_OBJ_NEW_SMALL_INT(sb.st_ino);
t->items[2] = MP_OBJ_NEW_SMALL_INT(sb.st_dev);
t->items[3] = MP_OBJ_NEW_SMALL_INT(sb.st_nlink);
t->items[4] = MP_OBJ_NEW_SMALL_INT(sb.st_uid);
t->items[5] = MP_OBJ_NEW_SMALL_INT(sb.st_gid);
t->items[1] = mp_obj_new_int_from_uint(sb.st_ino);
t->items[2] = mp_obj_new_int_from_uint(sb.st_dev);
t->items[3] = mp_obj_new_int_from_uint(sb.st_nlink);
t->items[4] = mp_obj_new_int_from_uint(sb.st_uid);
t->items[5] = mp_obj_new_int_from_uint(sb.st_gid);
t->items[6] = mp_obj_new_int_from_uint(sb.st_size);
t->items[7] = MP_OBJ_NEW_SMALL_INT(sb.st_atime);
t->items[8] = MP_OBJ_NEW_SMALL_INT(sb.st_mtime);
t->items[9] = MP_OBJ_NEW_SMALL_INT(sb.st_ctime);
t->items[7] = mp_obj_new_int_from_uint(sb.st_atime);
t->items[8] = mp_obj_new_int_from_uint(sb.st_mtime);
t->items[9] = mp_obj_new_int_from_uint(sb.st_ctime);
return MP_OBJ_FROM_PTR(t);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_stat_obj, mod_os_stat);

Loading…
Cancel
Save