Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
04d5e644
Commit
04d5e644
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/objarray: Fix array.append so it doesn't extend if append fails.
Addresses issue #1965.
parent
2c915e1a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/objarray.c
+3
-1
3 additions, 1 deletion
py/objarray.c
tests/basics/bytearray_append.py
+15
-0
15 additions, 0 deletions
tests/basics/bytearray_append.py
with
18 additions
and
1 deletion
py/objarray.c
+
3
−
1
View file @
04d5e644
...
...
@@ -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
));
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
--
;
return
mp_const_none
;
// return None, as per CPython
}
...
...
This diff is collapsed.
Click to expand it.
tests/basics/bytearray_append.py
0 → 100644
+
15
−
0
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment