Commit b86d9f57 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket #712: sequence unpacking of known types crashed the compiler

--HG--
extra : transplant_source : T%DD%B0%DA%C6.i%FF7%E9%28%F6%90%11%DC%CC%FA%D8jc
parent cf35cdf9
...@@ -4053,6 +4053,8 @@ class SequenceNode(ExprNode): ...@@ -4053,6 +4053,8 @@ class SequenceNode(ExprNode):
# Need to work around the fact that generate_evaluation_code # Need to work around the fact that generate_evaluation_code
# allocates the temps in a rather hacky way -- the assignment # allocates the temps in a rather hacky way -- the assignment
# is evaluated twice, within each if-block. # is evaluated twice, within each if-block.
for item in self.unpacked_items:
item.allocate(code)
special_unpack = (rhs.type is py_object_type special_unpack = (rhs.type is py_object_type
or rhs.type in (tuple_type, list_type) or rhs.type in (tuple_type, list_type)
or not rhs.type.is_builtin_type) or not rhs.type.is_builtin_type)
...@@ -4070,8 +4072,6 @@ class SequenceNode(ExprNode): ...@@ -4070,8 +4072,6 @@ class SequenceNode(ExprNode):
sequence_type_test = "(%s) || (%s)" % (tuple_check, list_check) sequence_type_test = "(%s) || (%s)" % (tuple_check, list_check)
code.putln("if (%s) {" % sequence_type_test) code.putln("if (%s) {" % sequence_type_test)
code.putln("PyObject* sequence = %s;" % rhs.py_result()) code.putln("PyObject* sequence = %s;" % rhs.py_result())
for item in self.unpacked_items:
item.allocate(code)
if len(sequence_types) == 2: if len(sequence_types) == 2:
code.putln("if (likely(Py%s_CheckExact(sequence))) {" % sequence_types[0]) code.putln("if (likely(Py%s_CheckExact(sequence))) {" % sequence_types[0])
self.generate_special_parallel_unpacking_code(code, sequence_types[0]) self.generate_special_parallel_unpacking_code(code, sequence_types[0])
......
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment