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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b386862c
Commit
b386862c
authored
Apr 19, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in Vitja's generators fix
parents
09bdd2b5
5d30ad61
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
13 deletions
+10
-13
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-3
tests/run/generators.pyx
tests/run/generators.pyx
+4
-3
tests/run/generators_py.py
tests/run/generators_py.py
+4
-7
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
b386862c
...
@@ -193,9 +193,8 @@ class PostParse(ScopeTrackingTransform):
...
@@ -193,9 +193,8 @@ class PostParse(ScopeTrackingTransform):
collector
=
YieldNodeCollector
()
collector
=
YieldNodeCollector
()
collector
.
visitchildren
(
node
.
result_expr
)
collector
.
visitchildren
(
node
.
result_expr
)
if
collector
.
yields
or
isinstance
(
node
.
result_expr
,
ExprNodes
.
YieldExprNode
):
if
collector
.
yields
or
isinstance
(
node
.
result_expr
,
ExprNodes
.
YieldExprNode
):
body
=
ExprNodes
.
YieldExprNode
(
body
=
Nodes
.
ExprStatNode
(
node
.
result_expr
.
pos
,
arg
=
node
.
result_expr
)
node
.
result_expr
.
pos
,
expr
=
node
.
result_expr
)
body
=
Nodes
.
ExprStatNode
(
node
.
result_expr
.
pos
,
expr
=
body
)
else
:
else
:
body
=
Nodes
.
ReturnStatNode
(
body
=
Nodes
.
ReturnStatNode
(
node
.
result_expr
.
pos
,
value
=
node
.
result_expr
)
node
.
result_expr
.
pos
,
value
=
node
.
result_expr
)
...
...
tests/run/generators.pyx
View file @
b386862c
...
@@ -295,10 +295,11 @@ def test_inside_lambda():
...
@@ -295,10 +295,11 @@ def test_inside_lambda():
>>> obj = test_inside_lambda()()
>>> obj = test_inside_lambda()()
>>> next(obj)
>>> next(obj)
1
1
>>>
obj.send('a'
)
>>>
next(obj
)
2
2
>>> obj.send('b')
>>> next(obj)
('a', 'b')
Traceback (most recent call last):
StopIteration
"""
"""
return
lambda
:((
yield
1
),
(
yield
2
))
return
lambda
:((
yield
1
),
(
yield
2
))
...
...
tests/run/generators_py.py
View file @
b386862c
...
@@ -7,10 +7,6 @@ except ImportError:
...
@@ -7,10 +7,6 @@ except ImportError:
def
next
(
it
):
def
next
(
it
):
return
it
.
next
()
return
it
.
next
()
if
hasattr
(
__builtins__
,
'GeneratorExit'
):
GeneratorExit
=
__builtins__
.
GeneratorExit
else
:
# < 2.5
GeneratorExit
=
StopIteration
def
very_simple
():
def
very_simple
():
"""
"""
...
@@ -280,10 +276,11 @@ def test_inside_lambda():
...
@@ -280,10 +276,11 @@ def test_inside_lambda():
>>> obj = test_inside_lambda()()
>>> obj = test_inside_lambda()()
>>> next(obj)
>>> next(obj)
1
1
>>>
obj.send('a'
)
>>>
next(obj
)
2
2
>>> obj.send('b')
>>> next(obj)
('a', 'b')
Traceback (most recent call last):
StopIteration
"""
"""
return
lambda
:((
yield
1
),
(
yield
2
))
return
lambda
:((
yield
1
),
(
yield
2
))
...
...
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