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
94b87c52
Commit
94b87c52
authored
Aug 07, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix DECREF(NULL) for empty comprehensions
parent
12a1d869
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-2
tests/run/cython3.pyx
tests/run/cython3.pyx
+23
-0
tests/run/listcomp.pyx
tests/run/listcomp.pyx
+4
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
94b87c52
...
...
@@ -7896,7 +7896,7 @@ class ScopedExprNode(ExprNode):
# normal (non-error) exit
for
entry
in
py_entries
:
code
.
put_var_decref_clear
(
entry
)
code
.
put_var_
x
decref_clear
(
entry
)
# error/loop body exit points
exit_scope
=
code
.
new_label
(
'exit_scope'
)
...
...
@@ -7906,7 +7906,7 @@ class ScopedExprNode(ExprNode):
if
code
.
label_used
(
label
):
code
.
put_label
(
label
)
for
entry
in
py_entries
:
code
.
put_var_decref_clear
(
entry
)
code
.
put_var_
x
decref_clear
(
entry
)
code
.
put_goto
(
old_label
)
code
.
put_label
(
exit_scope
)
code
.
putln
(
'} /* exit inner scope */'
)
...
...
tests/run/cython3.pyx
View file @
94b87c52
...
...
@@ -329,6 +329,7 @@ def loop_over_unicode_literal():
assert
uchar
in
'abcdefg'
return
cython
.
typeof
(
uchar
)
def
list_comp
():
"""
>>> list_comp()
...
...
@@ -339,6 +340,28 @@ def list_comp():
assert
x
==
'abc'
# don't leak in Py3 code
return
result
def
list_comp_iterable
(
it
):
"""
>>> list_comp_iterable([])
[]
>>> list_comp_iterable([0])
[0]
>>> list_comp_iterable([1])
[]
>>> list_comp_iterable([0, 1])
[0]
>>> list_comp_iterable([2])
[4]
>>> list_comp_iterable(range(5))
[0, 4, 8]
"""
x
=
'abc'
result
=
[
x
*
2
for
x
in
it
if
x
%
2
==
0
]
assert
x
==
'abc'
# don't leak in Py3 code
return
result
def
list_comp_with_lambda
():
"""
>>> list_comp_with_lambda()
...
...
tests/run/listcomp.pyx
View file @
94b87c52
...
...
@@ -97,6 +97,10 @@ def listcomp_as_condition(sequence):
@
cython
.
test_assert_path_exists
(
"//ComprehensionNode"
)
def
sorted_listcomp
(
sequence
):
"""
>>> sorted_listcomp([])
[]
>>> sorted_listcomp([1])
[2]
>>> sorted_listcomp([3,2,4])
[3, 4, 5]
"""
...
...
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