Johannes Wienke wrote:
> Hi,
>
> maybe I've just got a lack of understanding or I don't know...
>
> I've got a class that in general looks like this:
>
> cpdef class Foo:
> cdef char* myData
>
> cdef void setData(Foo self, char *data)
> self.myData = data
>
> cpdef doSomething(Foo self)
> print self.myData
>
> The problem is that working with myData directly from Cython is no
> problem but calling doSomething from the python interpreter causes a
> segfault because self.myData then points to NULL. I've also observed
> that self in setData points to a different address than self in
> doSomething if it is called from the interpreter.
Can you provide a full running session of what you try to do? I.e. can you
confirm that you do something like this:
Py> import foo
Py> a = foo.Foo()
Py> a.setData("aaaa")
Py> a.doSomething()
and it still crashes? (I'm guessing so...and in that case, I don't have a
clue, wait for somebody else to respond :-) ).
(But do double-check that the "self" argument is typed correctly. What
happens if you try to assign "self" to a cdef-ed local variable, i.e.
cdef Foo x = self
print x.myData
?)
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev