@@ -992,8 +992,13 @@ py_obj_t py_builtin___build_class__(py_obj_t o_class_fun, py_obj_t o_class_name)
992
992
return o ;
993
993
}
994
994
995
- py_obj_t py_builtin_range (py_obj_t o_arg ) {
996
- return py_obj_new_range (0 , py_obj_get_int (o_arg ), 1 );
995
+ py_obj_t py_builtin_range (int n_args , const py_obj_t * args ) {
996
+ switch (n_args ) {
997
+ case 1 : return py_obj_new_range (0 , py_obj_get_int (args [0 ]), 1 );
998
+ case 2 : return py_obj_new_range (py_obj_get_int (args [0 ]), py_obj_get_int (args [1 ]), 1 );
999
+ case 3 : return py_obj_new_range (py_obj_get_int (args [0 ]), py_obj_get_int (args [1 ]), py_obj_get_int (args [2 ]));
1000
+ default : nlr_jump (py_obj_new_exception_2 (q_TypeError , "range expected at most 3 arguments, got %d" , (void * )(machine_int_t )n_args , NULL ));
1001
+ }
997
1002
}
998
1003
999
1004
#ifdef WRITE_CODE
@@ -1031,7 +1036,7 @@ void rt_init(void) {
1031
1036
py_qstr_map_lookup (& map_builtins , qstr_from_str_static ("len" ), true)-> value = rt_make_function_1 (py_builtin_len );
1032
1037
py_qstr_map_lookup (& map_builtins , qstr_from_str_static ("abs" ), true)-> value = rt_make_function_1 (py_builtin_abs );
1033
1038
py_qstr_map_lookup (& map_builtins , q___build_class__ , true)-> value = rt_make_function_2 (py_builtin___build_class__ );
1034
- py_qstr_map_lookup (& map_builtins , qstr_from_str_static ("range" ), true)-> value = rt_make_function_1 ( py_builtin_range );
1039
+ py_qstr_map_lookup (& map_builtins , qstr_from_str_static ("range" ), true)-> value = rt_make_function_var ( 1 , py_builtin_range );
1035
1040
1036
1041
next_unique_code_id = 2 ; // 1 is reserved for the __main__ module scope
1037
1042
unique_codes = NULL ;
0 commit comments