Skip to content

Commit 7dbe4e9

Browse files
committed
Make slice make_new match mp_make_new_fun_t exactly, check the input type and enable it for qemu tests.
1 parent 75d6abe commit 7dbe4e9

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

py/objslice.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
129129
}
130130

131131
STATIC mp_obj_t slice_make_new(const mp_obj_type_t *type,
132-
mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
132+
size_t n_args, size_t n_kw, const mp_obj_t *args);
133133
#endif
134134

135135
const mp_obj_type_t mp_type_slice = {
@@ -153,7 +153,10 @@ mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
153153

154154
#if MICROPY_PY_BUILTINS_SLICE_ATTRS
155155
STATIC mp_obj_t slice_make_new(const mp_obj_type_t *type,
156-
mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
156+
size_t n_args, size_t n_kw, const mp_obj_t *args) {
157+
if (type != &mp_type_slice) {
158+
mp_raise_NotImplementedError("Cannot subclass slice");
159+
}
157160
// check number of arguments
158161
mp_arg_check_num(n_args, n_kw, 1, 3, false);
159162

qemu-arm/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
2121
#define MICROPY_PY_BUILTINS_FROZENSET (1)
2222
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
23+
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
2324
#define MICROPY_PY_IO (1)
2425
#define MICROPY_PY_SYS_EXIT (1)
2526
#define MICROPY_PY_SYS_MAXSIZE (1)

0 commit comments

Comments
 (0)