Fix #156, missing self in cpdef method.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 15 Mar 2009 05:45:55 +0000 (22:45 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 15 Mar 2009 05:45:55 +0000 (22:45 -0700)
--HG--
rename : tests/bugs/missing_self_in_cpdef_method_T156.pyx => tests/errors/missing_self_in_cpdef_method_T156.pyx

Cython/Compiler/Nodes.py
tests/bugs/missing_self_in_cpdef_method_T156.pyx [deleted file]
tests/errors/missing_self_in_cpdef_method_T156.pyx [new file with mode: 0644]

index 45920b4ff20cb17b474da9065fbcafe0e7fa8e1b..64572fb4f8e28d8f9dfe52870d36eebd443f3ca5 100644 (file)
@@ -1336,7 +1336,7 @@ class CFuncDefNode(FuncDefNode):
         self.entry.inline_func_in_pxd = self.inline_in_pxd
         self.return_type = type.return_type
         
-        if self.overridable:
+        if self.overridable and len(self.args) > 0:
             import ExprNodes
             py_func_body = self.call_self_node(is_module_scope = env.is_module_scope)
             self.py_func = DefNode(pos = self.pos, 
@@ -1393,7 +1393,7 @@ class CFuncDefNode(FuncDefNode):
 
     def analyse_expressions(self, env):
         self.analyse_default_values(env)
-        if self.overridable:
+        if self.py_func is not None:
             self.py_func.analyse_expressions(env)
 
     def generate_function_header(self, code, with_pymethdef, with_opt_args = 1, with_dispatch = 1, cname = None):
diff --git a/tests/bugs/missing_self_in_cpdef_method_T156.pyx b/tests/bugs/missing_self_in_cpdef_method_T156.pyx
deleted file mode 100644 (file)
index a7eb65b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-
-cdef class B:
-    cpdef b():
-        pass
-
diff --git a/tests/errors/missing_self_in_cpdef_method_T156.pyx b/tests/errors/missing_self_in_cpdef_method_T156.pyx
new file mode 100644 (file)
index 0000000..9296ba8
--- /dev/null
@@ -0,0 +1,8 @@
+
+cdef class B:
+    cpdef b():
+        pass
+
+_ERRORS = u"""
+:3:10: C method has no self argument
+"""