From 5c7683955994b965270598559e979c581ddc1950 Mon Sep 17 00:00:00 2001 From: John R. Lenton Date: Mon, 13 Jan 2014 05:12:50 +0000 Subject: sorted --- py/objlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'py/objlist.c') diff --git a/py/objlist.c b/py/objlist.c index fa8ec67d0..d5ea7f47b 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -248,13 +248,14 @@ static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, bool r } } -static mp_obj_t list_sort(mp_obj_t args, mp_map_t *kwargs) { +mp_obj_t list_sort(mp_obj_t args, mp_map_t *kwargs) { mp_obj_t *args_items = NULL; uint args_len = 0; assert(MP_OBJ_IS_TYPE(args, &tuple_type)); mp_obj_tuple_get(args, &args_len, &args_items); assert(args_len >= 1); + assert(MP_OBJ_IS_TYPE(args_items[0], &list_type)); if (args_len > 1) { nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "list.sort takes no positional arguments")); -- cgit v1.2.3 From 88cb1e60e0b780d71e9c2d7b0acafa71ba3ea318 Mon Sep 17 00:00:00 2001 From: John R. Lenton Date: Mon, 13 Jan 2014 19:55:18 +0000 Subject: Made sorted() raise an exception instead of aborting when given no arguments; moved around some things in objfun.c as a consequence --- py/objlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py/objlist.c') diff --git a/py/objlist.c b/py/objlist.c index d5ea7f47b..f806dfae8 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -381,7 +381,7 @@ static MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert); static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop); static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, list_remove); static MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse); -static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, list_sort); +static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 0, list_sort); static const mp_method_t list_type_methods[] = { { "append", &list_append_obj }, -- cgit v1.2.3