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
1801421f
Commit
1801421f
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
bytearray: Print objects properly.
parent
0b7e29c0
No related branches found
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
+10
-9
10 additions, 9 deletions
py/objarray.c
tests/basics/bytearray1.py
+1
-0
1 addition, 0 deletions
tests/basics/bytearray1.py
with
11 additions
and
9 deletions
py/objarray.c
+
10
−
9
View file @
1801421f
...
...
@@ -124,10 +124,10 @@ static void array_set_el(mp_obj_array_t *o, int index, mp_obj_t val_in) {
static
void
array_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
o_in
,
mp_print_kind_t
kind
)
{
mp_obj_array_t
*
o
=
o_in
;
if
(
o
->
typecode
==
BYTEARRAY_TYPECODE
)
{
print
(
env
,
"bytearray("
,
o
->
typecode
);
print
(
env
,
"bytearray(b"
,
o
->
typecode
);
mp_str_print_quoted
(
print
,
env
,
o
->
items
,
o
->
len
);
}
else
{
print
(
env
,
"array('%c'"
,
o
->
typecode
);
}
if
(
o
->
len
>
0
)
{
print
(
env
,
", ["
,
o
->
typecode
);
for
(
int
i
=
0
;
i
<
o
->
len
;
i
++
)
{
...
...
@@ -138,6 +138,7 @@ static void array_print(void (*print)(void *env, const char *fmt, ...), void *en
}
print
(
env
,
"]"
);
}
}
print
(
env
,
")"
);
}
...
...
This diff is collapsed.
Click to expand it.
tests/basics/bytearray1.py
+
1
−
0
View file @
1801421f
a
=
bytearray
([
1
,
2
,
200
])
print
(
a
[
0
],
a
[
2
])
print
(
a
[
-
1
])
print
(
a
)
a
[
2
]
=
255
print
(
a
[
-
1
])
a
.
append
(
10
)
...
...
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