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
4abd0ca8
Commit
4abd0ca8
authored
Feb 01, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:vitek/cython
parents
719f7569
3f34de4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-2
tests/run/generators.pyx
tests/run/generators.pyx
+16
-0
No files found.
Cython/Compiler/Nodes.py
View file @
4abd0ca8
...
...
@@ -2983,8 +2983,6 @@ class GeneratorBodyDefNode(DefNode):
# Generate closure function definitions
self
.
body
.
generate_function_definitions
(
lenv
,
code
)
# generate lambda function definitions
self
.
generate_lambda_definitions
(
lenv
,
code
)
# Generate C code for header and body of function
code
.
enter_cfunc_scope
()
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
4abd0ca8
...
...
@@ -1377,8 +1377,8 @@ class MarkClosureVisitor(CythonTransform):
collector
.
visitchildren
(
node
)
if
collector
.
yields
:
for
i
,
yield_expr
in
enumerate
(
collector
.
yields
):
yield_expr
.
label_num
=
i
+
1
for
i
,
yield_expr
in
enumerate
(
collector
.
yields
,
1
):
yield_expr
.
label_num
=
i
gbody
=
Nodes
.
GeneratorBodyDefNode
(
pos
=
node
.
pos
,
name
=
node
.
name
,
...
...
tests/run/generators.pyx
View file @
4abd0ca8
...
...
@@ -299,3 +299,19 @@ def test_inside_lambda():
('a', 'b')
"""
return
lambda
:((
yield
1
),
(
yield
2
))
def
test_nested_gen
(
int
n
):
"""
>>> [list(a) for a in test_nested_gen(5)]
[[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]
"""
for
a
in
range
(
n
):
yield
(
b
for
b
in
range
(
a
))
def
test_lambda
(
n
):
"""
>>> [i() for i in test_lambda(3)]
[0, 1, 2]
"""
for
i
in
range
(
n
):
yield
lambda
:
i
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