Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
be92c8b5
Commit
be92c8b5
authored
9 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add "gi_yieldfrom" to generators and "cr_await" to coroutines (Python issue 24450)
parent
7df9d654
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+4
-0
tests/run/yield_from_pep380.pyx
tests/run/yield_from_pep380.pyx
+15
-0
No files found.
Cython/Utility/Coroutine.c
View file @
be92c8b5
...
@@ -1172,6 +1172,8 @@ static PyMethodDef __pyx_Coroutine_methods[] = {
...
@@ -1172,6 +1172,8 @@ static PyMethodDef __pyx_Coroutine_methods[] = {
static
PyMemberDef
__pyx_Coroutine_memberlist
[]
=
{
static
PyMemberDef
__pyx_Coroutine_memberlist
[]
=
{
{(
char
*
)
"cr_running"
,
T_BOOL
,
offsetof
(
__pyx_CoroutineObject
,
is_running
),
READONLY
,
NULL
},
{(
char
*
)
"cr_running"
,
T_BOOL
,
offsetof
(
__pyx_CoroutineObject
,
is_running
),
READONLY
,
NULL
},
{(
char
*
)
"cr_yieldfrom"
,
T_OBJECT
,
offsetof
(
__pyx_CoroutineObject
,
yieldfrom
),
READONLY
,
(
char
*
)
PyDoc_STR
(
"object being awaited, or None"
)},
{
0
,
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
,
0
}
};
};
...
@@ -1288,6 +1290,8 @@ static PyMethodDef __pyx_Generator_methods[] = {
...
@@ -1288,6 +1290,8 @@ static PyMethodDef __pyx_Generator_methods[] = {
static
PyMemberDef
__pyx_Generator_memberlist
[]
=
{
static
PyMemberDef
__pyx_Generator_memberlist
[]
=
{
{(
char
*
)
"gi_running"
,
T_BOOL
,
offsetof
(
__pyx_CoroutineObject
,
is_running
),
READONLY
,
NULL
},
{(
char
*
)
"gi_running"
,
T_BOOL
,
offsetof
(
__pyx_CoroutineObject
,
is_running
),
READONLY
,
NULL
},
{(
char
*
)
"gi_yieldfrom"
,
T_OBJECT
,
offsetof
(
__pyx_CoroutineObject
,
yieldfrom
),
READONLY
,
(
char
*
)
PyDoc_STR
(
"object being iterated by 'yield from', or None"
)},
{
0
,
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
,
0
}
};
};
...
...
This diff is collapsed.
Click to expand it.
tests/run/yield_from_pep380.pyx
View file @
be92c8b5
...
@@ -1071,3 +1071,18 @@ def yield_in_return(x):
...
@@ -1071,3 +1071,18 @@ def yield_in_return(x):
True
True
"""
"""
return
(
yield
from
x
)
return
(
yield
from
x
)
def
gi_yieldfrom
(
it
):
"""
>>> it = iter([1, 2, 3])
>>> g = gi_yieldfrom(it)
>>> g.gi_yieldfrom is None or "ERROR: %r" % g.gi_yieldfrom
True
>>> next(g)
1
>>> g.gi_yieldfrom is it or "ERROR: %r" % g.gi_yieldfrom
True
"""
x
=
yield
from
it
return
x
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment