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
11973b48
Commit
11973b48
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
array.array: Allow to create empty arrays.
parent
42647e64
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/objarray.c
+10
-13
10 additions, 13 deletions
py/objarray.c
with
10 additions
and
13 deletions
py/objarray.c
+
10
−
13
View file @
11973b48
...
...
@@ -164,20 +164,17 @@ static mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
}
static
mp_obj_t
array_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
switch
(
n_args
)
{
case
2
:
{
if
(
n_args
<
1
||
n_args
>
2
)
{
nlr_jump
(
mp_obj_new_exception_msg_varg
(
MP_QSTR_TypeError
,
"unexpected # of arguments, %d given"
,
n_args
));
}
// TODO check args
uint
l
;
const
byte
*
s
=
mp_obj_str_get_data
(
args
[
0
],
&
l
);
mp_obj_t
initializer
=
args
[
1
];
return
array_
construct
(
*
s
,
initializer
);
const
byte
*
typecode
=
mp_obj_str_get_data
(
args
[
0
],
&
l
);
if
(
n_args
==
1
)
{
return
array_
new
(
*
typecode
,
0
);
}
default:
nlr_jump
(
mp_obj_new_exception_msg_varg
(
MP_QSTR_TypeError
,
"unexpected # of arguments, %d given"
,
n_args
));
}
return
NULL
;
return
array_construct
(
*
typecode
,
args
[
1
]);
}
// This is top-level factory function, not virtual method
...
...
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