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
1d755331
Commit
1d755331
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Plain Diff
Merge pull request #382 from pfalcon/genexit-inst
objgenerator: close(): Throw instance of GeneratorExit (not type).
parents
440f0415
c4d589e2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/obj.h
+1
-0
1 addition, 0 deletions
py/obj.h
py/objexcept.c
+6
-0
6 additions, 0 deletions
py/objexcept.c
py/objgenerator.c
+1
-1
1 addition, 1 deletion
py/objgenerator.c
with
8 additions
and
1 deletion
py/obj.h
+
1
−
0
View file @
1d755331
...
...
@@ -231,6 +231,7 @@ extern const mp_obj_t mp_const_false;
extern
const
mp_obj_t
mp_const_true
;
extern
const
mp_obj_t
mp_const_empty_tuple
;
extern
const
mp_obj_t
mp_const_ellipsis
;
extern
const
mp_obj_t
mp_const_GeneratorExit
;
// General API for objects
...
...
This diff is collapsed.
Click to expand it.
py/objexcept.c
+
6
−
0
View file @
1d755331
...
...
@@ -21,6 +21,12 @@ typedef struct mp_obj_exception_t {
mp_obj_tuple_t
args
;
}
mp_obj_exception_t
;
// Instance of GeneratorExit exception - needed by generator.close()
// This would belong to objgenerator.c, but to keep mp_obj_exception_t
// definition module-private so far, have it here.
STATIC
mp_obj_exception_t
GeneratorExit_obj
=
{{
&
mp_type_GeneratorExit
},
MP_OBJ_NULL
,
NULL
,
{{
&
tuple_type
},
0
}};
const
mp_obj_t
mp_const_GeneratorExit
=
(
mp_obj_t
)
&
GeneratorExit_obj
;
STATIC
void
mp_obj_exception_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
o_in
,
mp_print_kind_t
kind
)
{
mp_obj_exception_t
*
o
=
o_in
;
if
(
o
->
msg
!=
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
py/objgenerator.c
+
1
−
1
View file @
1d755331
...
...
@@ -171,7 +171,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_ins
STATIC
mp_obj_t
gen_instance_close
(
mp_obj_t
self_in
)
{
mp_obj_t
ret
;
switch
(
mp_obj_gen_resume
(
self_in
,
mp_const_none
,
(
mp_
obj_t
)
&
mp_type
_GeneratorExit
,
&
ret
))
{
switch
(
mp_obj_gen_resume
(
self_in
,
mp_const_none
,
mp_
const
_GeneratorExit
,
&
ret
))
{
case
MP_VM_RETURN_YIELD
:
nlr_jump
(
mp_obj_new_exception_msg
(
&
mp_type_RuntimeError
,
"generator ignored GeneratorExit"
));
...
...
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