Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
77f85db4
Commit
77f85db4
authored
Mar 14, 2016
by
Damien George
Browse files
py/objarray: Fix array slice assignment when array is reallocated.
Addresses issue #1898.
parent
06b39848
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/objarray.c
View file @
77f85db4
...
...
@@ -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
);
...
...
tests/basics/bytearray_slice_assign.py
View file @
77f85db4
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment