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
Kirill Smelkov
cython
Commits
65705d06
Commit
65705d06
authored
Oct 10, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.27.x'
parents
14b08598
2ad640d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-0
tests/run/listcomp.pyx
tests/run/listcomp.pyx
+51
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
65705d06
...
...
@@ -7984,6 +7984,7 @@ class ComprehensionNode(ScopedExprNode):
child_attrs
=
[
"loop"
]
is_temp
=
True
constant_result
=
not_a_constant
def
infer_type
(
self
,
env
):
return
self
.
type
...
...
tests/run/listcomp.pyx
View file @
65705d06
...
...
@@ -150,6 +150,57 @@ def listcomp_const_condition_false():
return
[
x
*
2
for
x
in
range
(
3
)
if
False
]
@
cython
.
test_fail_if_path_exists
(
"//IfStatNode"
,
"//ComprehensionAppendNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
)
def
listcomp_const_condition_false_bool_test
():
"""
>>> listcomp_const_condition_false_bool_test()
True
"""
return
not
[
l
for
l
in
[
1
]
if
False
]
@
cython
.
test_fail_if_path_exists
(
"//IfStatNode"
,
"//ComprehensionAppendNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
)
def
listcomp_const_condition_false_assert
():
"""
>>> listcomp_const_condition_false_assert()
"""
assert
not
[
l
for
l
in
[
1
]
if
False
]
@
cython
.
test_fail_if_path_exists
(
"//ComprehensionNode//IfStatNode"
,
"//ComprehensionAppendNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
,
"//IfStatNode"
)
def
listcomp_const_condition_false_if
():
"""
>>> listcomp_const_condition_false_if()
True
"""
if
not
[
l
for
l
in
[
1
]
if
False
]:
return
True
return
False
@
cython
.
test_fail_if_path_exists
(
"//ComprehensionNode//IfStatNode"
,
"//ComprehensionAppendNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
,
"//IfStatNode"
)
def
listcomp_const_condition_false_typed_error
():
"""
>>> listcomp_const_condition_false_typed_error() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""
cdef
str
l
if
not
[
l
for
l
in
[
1
]
if
False
]:
return
True
return
False
@
cython
.
test_fail_if_path_exists
(
"//IfStatNode"
)
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
,
"//ComprehensionAppendNode"
)
...
...
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