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
Gwenaël Samain
cython
Commits
9de47b5e
Commit
9de47b5e
authored
Dec 19, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for-from loop in list comprehensions
parent
ccd65093
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+5
-1
tests/run/forfrom.pyx
tests/run/forfrom.pyx
+19
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
9de47b5e
...
...
@@ -625,8 +625,12 @@ class ComprehensionTransform(VisitorTransform):
# replace name references in the loop code by their temp node
self
.
visitchildren
(
node
,
[
'loop'
])
self
.
comprehension_targets
=
outer_comprehension_targets
loop
=
node
.
loop
if
type
(
loop
)
is
Nodes
.
ForFromStatNode
and
loop
.
target
.
type
.
is_numeric
:
loop
.
loopvar_node
=
loop
.
target
node
.
loop
=
TempsBlockNode
(
node
.
pos
,
body
=
node
.
loop
,
temps
=
temps
)
self
.
comprehension_targets
=
outer_comprehension_targets
return
node
def
visit_NameNode
(
self
,
node
):
...
...
tests/run/forfrom.pyx
0 → 100644
View file @
9de47b5e
u"""
>>> for_else()
30
>>> print( u'*'.join(int_comp()) )
00*01*02
"""
def
for_else
():
cdef
int
i
,
j
=
0
,
k
=
2
for
i
from
0
<=
i
<
10
:
j
+=
k
else
:
k
=
j
+
10
return
k
def
int_comp
():
cdef
int
i
return
tuple
([
u"%02d"
%
i
for
i
from
0
<=
i
<
3
])
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