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
ee014110
Commit
ee014110
authored
Apr 15, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Add len(bytes).
parent
897fe0c0
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/obj.c
+1
-1
1 addition, 1 deletion
py/obj.c
py/objstr.c
+2
-1
2 additions, 1 deletion
py/objstr.c
with
3 additions
and
2 deletions
py/obj.c
+
1
−
1
View file @
ee014110
...
@@ -320,7 +320,7 @@ uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index,
...
@@ -320,7 +320,7 @@ uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index,
// may return MP_OBJ_NULL
// may return MP_OBJ_NULL
mp_obj_t
mp_obj_len_maybe
(
mp_obj_t
o_in
)
{
mp_obj_t
mp_obj_len_maybe
(
mp_obj_t
o_in
)
{
if
(
MP_OBJ_IS_STR
(
o_in
))
{
if
(
MP_OBJ_IS_STR
(
o_in
)
||
MP_OBJ_IS_TYPE
(
o_in
,
&
mp_type_bytes
)
)
{
return
MP_OBJ_NEW_SMALL_INT
((
machine_int_t
)
mp_obj_str_get_len
(
o_in
));
return
MP_OBJ_NEW_SMALL_INT
((
machine_int_t
)
mp_obj_str_get_len
(
o_in
));
}
else
{
}
else
{
mp_obj_type_t
*
type
=
mp_obj_get_type
(
o_in
);
mp_obj_type_t
*
type
=
mp_obj_get_type
(
o_in
);
...
...
This diff is collapsed.
Click to expand it.
py/objstr.c
+
2
−
1
View file @
ee014110
...
@@ -1485,7 +1485,8 @@ uint mp_obj_str_get_hash(mp_obj_t self_in) {
...
@@ -1485,7 +1485,8 @@ uint mp_obj_str_get_hash(mp_obj_t self_in) {
}
}
uint
mp_obj_str_get_len
(
mp_obj_t
self_in
)
{
uint
mp_obj_str_get_len
(
mp_obj_t
self_in
)
{
if
(
MP_OBJ_IS_STR
(
self_in
))
{
// TODO This has a double check for the type, one in obj.c and one here
if
(
MP_OBJ_IS_STR
(
self_in
)
||
MP_OBJ_IS_TYPE
(
self_in
,
&
mp_type_bytes
))
{
GET_STR_LEN
(
self_in
,
l
);
GET_STR_LEN
(
self_in
,
l
);
return
l
;
return
l
;
}
else
{
}
else
{
...
...
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