8000 Merge remote-tracking branch 'origin/main' into main · domdfcoding/circuitpython@b6c8098 · GitHub
[go: up one dir, main page]

Skip to content

Commit b6c8098

Browse files
committed
Merge remote-tracking branch 'origin/main' into main
2 parents 0bd181c + 98002cf commit b6c8098

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

py/objarray.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args,
195195
// no args: construct an empty bytearray
196196
return MP_OBJ_FROM_PTR(array_new(BYTEARRAY_TYPECODE, 0));
197197
} else if (mp_obj_is_int(args[0])) {
198+
if (n_args > 1) {
199+
mp_raise_TypeError(MP_ERROR_TEXT("wrong number of arguments"));
200+
}
198201
// 1 arg, an integer: construct a blank bytearray of that length
199202
mp_uint_t len = mp_obj_get_int(args[0]);
200203
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, len);

py/objstr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons
233233
return MP_OBJ_FROM_PTR(o);
234234
}
235235

236+
if (n_args > 1) {
237+
goto wrong_args;
238+
}
239+
236240
if (mp_obj_is_small_int(args[0])) {
237241
mp_int_t len = MP_OBJ_SMALL_INT_VALUE(args[0]);
238242 7659
if (len < 0) {
@@ -244,10 +248,6 @@ STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, cons
244248
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
245249
}
246250

247-
if (n_args > 1) {
248-
goto wrong_args;
249-
}
250-
251251
// check if __bytes__ exists, and if so delegate to it
252252
mp_obj_t dest[2];
253253
mp_load_method_maybe(args[0], MP_QSTR___bytes__, dest);

0 commit comments

Comments
 (0)
0