fix for #59: compiler crash when special signatures where declared with cdef
authorStefan Behnel <scoder@users.berlios.de>
Fri, 5 Sep 2008 10:08:42 +0000 (12:08 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 5 Sep 2008 10:08:42 +0000 (12:08 +0200)
Cython/Compiler/ModuleNode.py
tests/errors/cdefspecial.pyx [new file with mode: 0644]

index 6beaa6fa4d7ce69b8a24f07fb9c599a9cfc5afd2..6d3100eb35d2cad396b12f7ecfd2e78de2562239 100644 (file)
@@ -872,7 +872,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
             else:
                 code.put_init_var_to_py_none(entry, "p->%s")
         entry = scope.lookup_here("__new__")
-        if entry:
+        if entry and entry.is_special:
             if entry.trivial_signature:
                 cinit_args = "o, %s, NULL" % Naming.empty_tuple
             else:
diff --git a/tests/errors/cdefspecial.pyx b/tests/errors/cdefspecial.pyx
new file mode 100644 (file)
index 0000000..53a484e
--- /dev/null
@@ -0,0 +1,12 @@
+
+cdef class Test:
+    cdef __cinit__(self):
+        pass
+
+    cdef __len__(self):
+        pass
+
+_ERRORS = u"""
+3:9: Special methods must be declared with 'def', not 'cdef'
+6:9: Special methods must be declared with 'def', not 'cdef'
+"""