On Tue, Mar 22, 2011 at 7:21 AM, Simon Anders <and...@embl.de> wrote: > Hi, > > I found a little bug in Cython 0.14.1. > > The following causes the Cython compiler to throw an exception: > > ---8<--- > cdef extern from "foo.h": > cdef cppclass foo[ T ]: > bar( int b = 0 ) > > cdef foo[ int ] a > a.bar( 1 ) > ---8<--- > > The exception is "AttributeError: 'CFuncType' object has no attribute > 'op_arg_struct'", thrown in line 3044, in generate_result_code. Full stack > trace attached. > > The file compiles without crash if one either > - removes the last line, i.e. the call to the class's method, or > - removes the template argument, i.e., the "[ T ]" in line 2 and > the "[ int ]" in line 5. > > Hence, the issue only appears when calling methods of _templated_ classes, > which have a _default_ value for their argument.
Default arguments in C++ are completely different from default arguments in Cython, this is our bug for not catching that. You have to declare this as an overloaded method cdef extern from "foo.h": cdef cppclass foo[ T ]: bar() bar(int) Btw, unless it returns an object, you probably want to declare the return type of your methods. Perhaps we should make this a warning for extern declarations? - Robert _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel