From: Robert Bradshaw Date: Fri, 18 Feb 2011 21:39:37 +0000 (-0800) Subject: del test and assignment fix X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d1ff05f2dc8991ca0d14f6fab535433c45257425;p=cython.git del test and assignment fix --- diff --git a/Cython/Compiler/TypeInference.py b/Cython/Compiler/TypeInference.py index 857a28b0..c788d02c 100644 --- a/Cython/Compiler/TypeInference.py +++ b/Cython/Compiler/TypeInference.py @@ -121,6 +121,12 @@ class MarkAssignments(CythonTransform): self.visitchildren(node) return node + def visit_DelStatNode(self, node): + for arg in node.args: + self.mark_assignment(arg, arg) + self.visitchildren(node) + return node + class MarkOverflowingArithmetic(CythonTransform): # It may be possible to integrate this with the above for diff --git a/tests/errors/e_del2.pyx b/tests/errors/e_del2.pyx deleted file mode 100644 index 20dac71a..00000000 --- a/tests/errors/e_del2.pyx +++ /dev/null @@ -1,12 +0,0 @@ -# Errors reported during code generation. - -cdef int i - -def f(a): - del a # error: deletion of local name not supported - del i # error: deletion of local name not supported - -_ERRORS = u""" -6:52: Deletion of local or C global name not supported -7:52: Deletion of local or C global name not supported -""" diff --git a/tests/run/delete.pyx b/tests/run/delete.pyx index 2aabbf42..7157078a 100644 --- a/tests/run/delete.pyx +++ b/tests/run/delete.pyx @@ -80,3 +80,10 @@ def del_temp_slice(a): while a.attr: del a.attr[:] return a.attr + +def del_local(a): + """ + >>> del_local(object()) + """ + del a + assert a is None # Until we have unbound locals...