py/objarray: Fix array slice assignment when array is reallocated.

Addresses issue #1898.
pull/1811/merge
Damien George 2016-03-14 23:12:54 +00:00
rodzic 06b398489e
commit 77f85db41e
2 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -439,6 +439,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
// TODO: alloc policy; at the moment we go conservative
o->items = m_renew(byte, o->items, (o->len + o->free) * item_sz, (o->len + len_adj) * item_sz);
o->free = 0;
dest_items = o->items;
}
mp_seq_replace_slice_grow_inplace(dest_items, o->len,
slice.start, slice.stop, src_items, src_len, len_adj, item_sz);

Wyświetl plik

@ -47,6 +47,9 @@ b = bytearray(2)
b[2:] = bytearray(10)
print(b)
b = bytearray(10)
b[:-1] = bytearray(500)
print(len(b), b[0], b[-1])
# Assignment of bytes to array slice
b = bytearray(2)