Commit 0b25d4b9 authored by Vitja Makarov's avatar Vitja Makarov

Handle sequence in DelStatNode, see #668

parent 16370195
...@@ -3785,12 +3785,23 @@ class DelStatNode(StatNode): ...@@ -3785,12 +3785,23 @@ class DelStatNode(StatNode):
child_attrs = ["args"] child_attrs = ["args"]
def flatten_args(self):
return self._flatten_args(self, [])
def _flatten_args(self, seq, result):
for arg in seq.args:
if arg.is_sequence_constructor:
self._flatten_args(arg, result)
else:
result.append(arg)
return result
def analyse_declarations(self, env): def analyse_declarations(self, env):
for arg in self.args: for arg in self.flatten_args():
arg.analyse_target_declaration(env) arg.analyse_target_declaration(env)
def analyse_expressions(self, env): def analyse_expressions(self, env):
for arg in self.args: for arg in self.flatten_args():
arg.analyse_target_expression(env, None) arg.analyse_target_expression(env, None)
if arg.type.is_pyobject: if arg.type.is_pyobject:
pass pass
...@@ -3803,14 +3814,14 @@ class DelStatNode(StatNode): ...@@ -3803,14 +3814,14 @@ class DelStatNode(StatNode):
#arg.release_target_temp(env) #arg.release_target_temp(env)
def nogil_check(self, env): def nogil_check(self, env):
for arg in self.args: for arg in self.flatten_args():
if arg.type.is_pyobject: if arg.type.is_pyobject:
self.gil_error() self.gil_error()
gil_message = "Deleting Python object" gil_message = "Deleting Python object"
def generate_execution_code(self, code): def generate_execution_code(self, code):
for arg in self.args: for arg in self.flatten_args():
if arg.type.is_pyobject: if arg.type.is_pyobject:
arg.generate_deletion_code(code) arg.generate_deletion_code(code)
elif arg.type.is_ptr and arg.type.base_type.is_cpp_class: elif arg.type.is_ptr and arg.type.base_type.is_cpp_class:
......
...@@ -122,7 +122,7 @@ class MarkAssignments(CythonTransform): ...@@ -122,7 +122,7 @@ class MarkAssignments(CythonTransform):
return node return node
def visit_DelStatNode(self, node): def visit_DelStatNode(self, node):
for arg in node.args: for arg in node.flatten_args():
self.mark_assignment(arg, arg) self.mark_assignment(arg, arg)
self.visitchildren(node) self.visitchildren(node)
return node return node
......
...@@ -87,3 +87,12 @@ def del_local(a): ...@@ -87,3 +87,12 @@ def del_local(a):
""" """
del a del a
assert a is None # Until we have unbound locals... assert a is None # Until we have unbound locals...
def del_seq(a, b, c):
"""
>>> del_seq(1, 2, 3)
"""
del a, (b, c)
assert a is None # Until we have unbound locals...
assert b is None # Until we have unbound locals...
assert c is None # Until we have unbound locals...
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