From e46c93f1a3f37e29e05fbf33e76abaedb0ce2643 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 18 Feb 2011 13:13:41 -0800 Subject: [PATCH] Emulate del with set to None. --- Cython/Compiler/ExprNodes.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 5b339da9..1772e6d9 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1674,20 +1674,22 @@ class NameNode(AtomicExprNode): def generate_deletion_code(self, code): if self.entry is None: return # There was an error earlier - if not self.entry.is_pyglobal: - error(self.pos, "Deletion of local or C global name not supported") - return - if self.entry.is_pyclass_attr: + elif self.entry.is_pyglobal: + code.put_error_if_neg(self.pos, + '__Pyx_DelAttrString(%s, "%s")' % ( + Naming.module_cname, + self.entry.name)) + elif self.entry.is_pyclass_attr: namespace = self.entry.scope.namespace_cname code.put_error_if_neg(self.pos, 'PyMapping_DelItemString(%s, "%s")' % ( namespace, self.entry.name)) + elif self.entry.type.is_pyobject: + # Fake it until we can do it for real... + self.generate_assignment_code(NoneNode(self.pos), code) else: - code.put_error_if_neg(self.pos, - '__Pyx_DelAttrString(%s, "%s")' % ( - Naming.module_cname, - self.entry.name)) + error(self.pos, "Deletion of C names not supported") def annotate(self, code): if hasattr(self, 'is_called') and self.is_called: -- 2.26.2