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
ffea991b
Commit
ffea991b
authored
Aug 15, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket #712: sequence unpacking of known types crashed the compiler
parent
e0fa6040
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-2
tests/run/tupleunpack_T712.pyx
tests/run/tupleunpack_T712.pyx
+18
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
ffea991b
...
...
@@ -4055,6 +4055,8 @@ class SequenceNode(ExprNode):
# Need to work around the fact that generate_evaluation_code
# allocates the temps in a rather hacky way -- the assignment
# is evaluated twice, within each if-block.
for
item
in
self
.
unpacked_items
:
item
.
allocate
(
code
)
special_unpack
=
(
rhs
.
type
is
py_object_type
or
rhs
.
type
in
(
tuple_type
,
list_type
)
or
not
rhs
.
type
.
is_builtin_type
)
...
...
@@ -4072,8 +4074,6 @@ class SequenceNode(ExprNode):
sequence_type_test
=
"(%s) || (%s)"
%
(
tuple_check
,
list_check
)
code
.
putln
(
"if (%s) {"
%
sequence_type_test
)
code
.
putln
(
"PyObject* sequence = %s;"
%
rhs
.
py_result
())
for
item
in
self
.
unpacked_items
:
item
.
allocate
(
code
)
if
len
(
sequence_types
)
==
2
:
code
.
putln
(
"if (likely(Py%s_CheckExact(sequence))) {"
%
sequence_types
[
0
])
self
.
generate_special_parallel_unpacking_code
(
code
,
sequence_types
[
0
])
...
...
tests/run/tupleunpack_T712.pyx
0 → 100644
View file @
ffea991b
# mode: run
# ticket: 712
def
single_from_string
():
"""
>>> print(single_from_string())
a
"""
(
a
,)
=
'a'
return
a
def
single_from_set
():
"""
>>> print(single_from_set())
a
"""
(
a
,)
=
set
([
"a"
])
return
a
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