Skip to content

Commit 194117a

Browse files
committed
objstr: Fix bytes creation from array of long ints.
1 parent 2863153 commit 194117a

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
223223
mp_obj_t iterable = mp_getiter(args[0]);
224224
mp_obj_t item;
225225
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
226-
vstr_add_byte(&vstr, MP_OBJ_SMALL_INT_VALUE(item));
226+
vstr_add_byte(&vstr, mp_obj_get_int(item));
227227
}
228228

229229
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);

tests/basics/bytes_construct.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
print(bytes(array('b', [1, 2])))
1212
print(bytes(array('h', [1, 2])))
1313
print(bytes(array('I', [1, 2])))
14+
15+
# long ints
16+
print(ord(bytes([14953042807679334000 & 0xff])))

0 commit comments

Comments
 (0)