From 8dbd550c002c81ba032f9c7017b6b9f7e3ec0781 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 14 Mar 2009 22:45:55 -0700 Subject: [PATCH] Fix #156, missing self in cpdef method. --HG-- rename : tests/bugs/missing_self_in_cpdef_method_T156.pyx => tests/errors/missing_self_in_cpdef_method_T156.pyx --- Cython/Compiler/Nodes.py | 4 ++-- tests/bugs/missing_self_in_cpdef_method_T156.pyx | 5 ----- tests/errors/missing_self_in_cpdef_method_T156.pyx | 8 ++++++++ 3 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 tests/bugs/missing_self_in_cpdef_method_T156.pyx create mode 100644 tests/errors/missing_self_in_cpdef_method_T156.pyx diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 45920b4f..64572fb4 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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 index a7eb65b3..00000000 --- a/tests/bugs/missing_self_in_cpdef_method_T156.pyx +++ /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 index 00000000..9296ba8a --- /dev/null +++ b/tests/errors/missing_self_in_cpdef_method_T156.pyx @@ -0,0 +1,8 @@ + +cdef class B: + cpdef b(): + pass + +_ERRORS = u""" +:3:10: C method has no self argument +""" -- 2.26.2