On Sep 7, 2009, at 10:51 AM, Philip Smith wrote:

> Hi
>
> I am relatively new to Cython but making good progress I think.   
> However I have the following code (skeleton) related to a library  
> I’m wrapping:
>
[code]
> This compiles absolutely fine (under Mingw) but crashes at runtime.
>
>  Any ideas?
>

Sorry no ones's gotten back to you yet. I'm not sure what the issue  
is, it works fine on OS X (see code below). Perhaps you should be  
checking for None in your __iadd__?

- Robert

cdef class Foo:
     cdef int i
     def __init__(self, i):
         self.i = i
     def __repr__(self):
         return "Foo(%s)" % self.i
     def __iadd__(self, Foo other not None):
         self.i += other.i
         return self

cdef class Foo2(object):
     cdef Foo attribute
     def __init__(self, Foo a):
         self.attribute = a
     def __iadd__(self, Foo2 other not None):
         self.attribute+=other.attribute               #This is  
defined in class foo and works fine there
         return self
     def __repr__(self):
         return "Foo2(%s)" % self.attribute


sage: from add import Foo, Foo2
sage: a = Foo2(Foo(3)); a
Foo2(Foo(3))
sage: b = Foo2(Foo(4)); b
Foo2(Foo(4))
sage: a += b
sage: a
Foo2(Foo(7))

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to