Emulate del with set to None.
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 18 Feb 2011 21:13:41 +0000 (13:13 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 18 Feb 2011 21:13:41 +0000 (13:13 -0800)
Cython/Compiler/ExprNodes.py

index 5b339da9423f29777883b736da3c80102d2d09d9..1772e6d90fe5a10d67889540e4824c5641b3e6f2 100755 (executable)
@@ -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: