Skip to content

Commit 343ca1e

Browse files
committed
objarray: Make sure that longint works as bytearray size.
1 parent 51af362 commit 343ca1e

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

py/objarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
191191
if (n_args == 0) {
192192
// no args: construct an empty bytearray
193193
return array_new(BYTEARRAY_TYPECODE, 0);
194-
} else if (MP_OBJ_IS_SMALL_INT(args[0])) {
194+
} else if (MP_OBJ_IS_INT(args[0])) {
195195
// 1 arg, an integer: construct a blank bytearray of that length
196-
mp_uint_t len = MP_OBJ_SMALL_INT_VALUE(args[0]);
196+
mp_uint_t len = mp_obj_get_int(args[0]);
197197
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, len);
198198
memset(o->items, 0, len);
199199
return o;

tests/basics/bytearray_longint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print(bytearray(2**65 - (2**65 - 1)))

0 commit comments

Comments
 (0)