Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
04d5e644
Commit
04d5e644
authored
Apr 07, 2016
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py/objarray: Fix array.append so it doesn't extend if append fails.
Addresses issue #1965.
parent
2c915e1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
py/objarray.c
py/objarray.c
+3
-1
tests/basics/bytearray_append.py
tests/basics/bytearray_append.py
+15
-0
No files found.
py/objarray.c
View file @
04d5e644
...
@@ -336,7 +336,9 @@ STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
...
@@ -336,7 +336,9 @@ STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
self
->
items
=
m_renew
(
byte
,
self
->
items
,
item_sz
*
self
->
len
,
item_sz
*
(
self
->
len
+
self
->
free
));
self
->
items
=
m_renew
(
byte
,
self
->
items
,
item_sz
*
self
->
len
,
item_sz
*
(
self
->
len
+
self
->
free
));
mp_seq_clear
(
self
->
items
,
self
->
len
+
1
,
self
->
len
+
self
->
free
,
item_sz
);
mp_seq_clear
(
self
->
items
,
self
->
len
+
1
,
self
->
len
+
self
->
free
,
item_sz
);
}
}
mp_binary_set_val_array
(
self
->
typecode
,
self
->
items
,
self
->
len
++
,
arg
);
mp_binary_set_val_array
(
self
->
typecode
,
self
->
items
,
self
->
len
,
arg
);
// only update length/free if set succeeded
self
->
len
++
;
self
->
free
--
;
self
->
free
--
;
return
mp_const_none
;
// return None, as per CPython
return
mp_const_none
;
// return None, as per CPython
}
}
...
...
tests/basics/bytearray_append.py
0 → 100644
View file @
04d5e644
# test bytearray.append method
a
=
bytearray
(
4
)
print
(
a
)
# append should append a single byte
a
.
append
(
2
)
print
(
a
)
# a should not be modified if append fails
try
:
a
.
append
(
None
)
except
TypeError
:
print
(
'TypeError'
)
print
(
a
)
Write
Preview
Markdown
is supported
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