Skip to content

Commit 330cf6d

Browse files
committed
Change id to return signed integer.
1 parent 0ebf853 commit 330cf6d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

py/builtin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
366366
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_bytes_obj, 1, 3, mp_builtin_bytes);
367367

368368
static mp_obj_t mp_builtin_id(mp_obj_t o_in) {
369-
return mp_obj_new_int_from_uint((machine_uint_t)o_in);
369+
return mp_obj_new_int((machine_int_t)o_in);
370370
}
371371

372372
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id);

tests/basics/builtin_id.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
print(id(1) == id(2))
22
print(id(None) == id(None))
3+
print(id([]) == id([]))
4+
5+
l = [1, 2]
6+
print(id(l) == id(l))
7+
8+
f = lambda:None
9+
print(id(f) == id(f))

0 commit comments

Comments
 (0)