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
GitLab 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
343ca1e6
Commit
343ca1e6
authored
Jan 4, 2015
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
objarray: Make sure that longint works as bytearray size.
parent
51af362e
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
+2
-2
2 additions, 2 deletions
py/objarray.c
tests/basics/bytearray_longint.py
+1
-0
1 addition, 0 deletions
tests/basics/bytearray_longint.py
with
3 additions
and
2 deletions
py/objarray.c
+
2
−
2
View file @
343ca1e6
...
...
@@ -191,9 +191,9 @@ STATIC mp_obj_t bytearray_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
if
(
n_args
==
0
)
{
// no args: construct an empty bytearray
return
array_new
(
BYTEARRAY_TYPECODE
,
0
);
}
else
if
(
MP_OBJ_IS_
SMALL_
INT
(
args
[
0
]))
{
}
else
if
(
MP_OBJ_IS_INT
(
args
[
0
]))
{
// 1 arg, an integer: construct a blank bytearray of that length
mp_uint_t
len
=
MP_OBJ_SMALL_INT_VALUE
(
args
[
0
]);
mp_uint_t
len
=
mp_obj_get_int
(
args
[
0
]);
mp_obj_array_t
*
o
=
array_new
(
BYTEARRAY_TYPECODE
,
len
);
memset
(
o
->
items
,
0
,
len
);
return
o
;
...
...
This diff is collapsed.
Click to expand it.
tests/basics/bytearray_longint.py
0 → 100644
+
1
−
0
View file @
343ca1e6
print
(
bytearray
(
2
**
65
-
(
2
**
65
-
1
)))
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