Commit 0385b215 authored by Damien George's avatar Damien George

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: default avatarDamien George <damien@micropython.org>
parent c70e5996
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment