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
eff85bb1
Commit
eff85bb1
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
py/vm: "yield from" didn't handle MP_OBJ_STOP_ITERATION optimization.
E.g. crashed when yielding from already stopped generators.
parent
d54290f6
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/objgenerator.c
+1
-0
1 addition, 0 deletions
py/objgenerator.c
py/vm.c
+2
-1
2 additions, 1 deletion
py/vm.c
with
3 additions
and
1 deletion
py/objgenerator.c
+
1
−
0
View file @
eff85bb1
...
@@ -99,6 +99,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
...
@@ -99,6 +99,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
assert
(
MP_OBJ_IS_TYPE
(
self_in
,
&
mp_type_gen_instance
));
assert
(
MP_OBJ_IS_TYPE
(
self_in
,
&
mp_type_gen_instance
));
mp_obj_gen_instance_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
mp_obj_gen_instance_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
if
(
self
->
code_state
.
ip
==
0
)
{
if
(
self
->
code_state
.
ip
==
0
)
{
// Trying to resume already stopped generator
*
ret_val
=
MP_OBJ_STOP_ITERATION
;
*
ret_val
=
MP_OBJ_STOP_ITERATION
;
return
MP_VM_RETURN_NORMAL
;
return
MP_VM_RETURN_NORMAL
;
}
}
...
...
This diff is collapsed.
Click to expand it.
py/vm.c
+
2
−
1
View file @
eff85bb1
...
@@ -1144,7 +1144,8 @@ yield:
...
@@ -1144,7 +1144,8 @@ yield:
if
(
ret_kind
==
MP_VM_RETURN_NORMAL
)
{
if
(
ret_kind
==
MP_VM_RETURN_NORMAL
)
{
// Pop exhausted gen
// Pop exhausted gen
sp
--
;
sp
--
;
if
(
ret_value
==
MP_OBJ_NULL
)
{
// TODO: When ret_value can be MP_OBJ_NULL here??
if
(
ret_value
==
MP_OBJ_NULL
||
ret_value
==
MP_OBJ_STOP_ITERATION
)
{
// Optimize StopIteration
// Optimize StopIteration
// TODO: get StopIteration's value
// TODO: get StopIteration's value
PUSH
(
mp_const_none
);
PUSH
(
mp_const_none
);
...
...
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