cython-devel
changeset 1880:3aac44b1f28a
Fix bad self argument crash in cpdef methods (#165)
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Wed Mar 25 15:00:06 2009 -0700 (2 years ago) |
| parents | 07c1e0dc312b |
| children | dc7359d237b9 |
| files | Cython/Compiler/Nodes.py tests/bugs/missing_self_in_cpdef_method_T165.pyx tests/errors/missing_self_in_cpdef_method_T165.pyx |
line diff
1.1 --- a/Cython/Compiler/Nodes.py Thu Mar 19 11:58:58 2009 -0700
1.2 +++ b/Cython/Compiler/Nodes.py Wed Mar 25 15:00:06 2009 -0700
1.3 @@ -1337,7 +1337,12 @@
1.4 self.entry.inline_func_in_pxd = self.inline_in_pxd
1.5 self.return_type = type.return_type
1.6
1.7 - if self.overridable and len(self.args) > 0:
1.8 + if self.overridable and not env.is_module_scope:
1.9 + if len(self.args) < 1 or not self.args[0].type.is_pyobject:
1.10 + # An error will be produced in the cdef function
1.11 + self.overridable = False
1.12 +
1.13 + if self.overridable:
1.14 import ExprNodes
1.15 py_func_body = self.call_self_node(is_module_scope = env.is_module_scope)
1.16 self.py_func = DefNode(pos = self.pos,
2.1 --- a/tests/bugs/missing_self_in_cpdef_method_T165.pyx Thu Mar 19 11:58:58 2009 -0700
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,5 +0,0 @@
2.4 -
2.5 -cdef class A:
2.6 - cpdef a(int not_self):
2.7 - pass
2.8 -
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tests/errors/missing_self_in_cpdef_method_T165.pyx Wed Mar 25 15:00:06 2009 -0700
3.3 @@ -0,0 +1,8 @@
3.4 +
3.5 +cdef class A:
3.6 + cpdef a(int not_self):
3.7 + pass
3.8 +
3.9 +_ERRORS = u"""
3.10 +3:10: Self argument (int) of C method 'a' does not match parent type (A)
3.11 +"""
