From 330cf6d04a5825d606fa5cb34eed0062a4e764b3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 2 Feb 2014 13:38:21 +0000 Subject: [PATCH] Change id to return signed integer. --- py/builtin.c | 2 +- tests/basics/builtin_id.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/py/builtin.c b/py/builtin.c index 333119bca6..4564d15756 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -366,7 +366,7 @@ static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) { MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_bytes_obj, 1, 3, mp_builtin_bytes); static mp_obj_t mp_builtin_id(mp_obj_t o_in) { - return mp_obj_new_int_from_uint((machine_uint_t)o_in); + return mp_obj_new_int((machine_int_t)o_in); } MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id); diff --git a/tests/basics/builtin_id.py b/tests/basics/builtin_id.py index de236945f0..4874f355b4 100644 --- a/tests/basics/builtin_id.py +++ b/tests/basics/builtin_id.py @@ -1,2 +1,9 @@ print(id(1) == id(2)) print(id(None) == id(None)) +print(id([]) == id([])) + +l = [1, 2] +print(id(l) == id(l)) + +f = lambda:None +print(id(f) == id(f))