Johannes Wienke wrote:
> I remember there was something about increasing the reference count of
> python objects that are stored by C code without without the notice of
> python. But how to achieve this? I thought there was a section in the
> cython manual about that but I can't find it.
>
> What I tried is:
> cdef extern from "Python.h":
>       Py_INCREF(obj)
>       Py_DECREF(obj)
>
> Py_INCREF(dataElement)

If you define these two functions (or macros) that way, Pyrex/Cython will
assume they are functions that work on an object (which is ok) and that
will return an object (which is not ok), and it will check the result for
NULL etc.

You can define them this way:

  cdef extern from "Python.h":
    cdef void Py_INCREF(object o)
    cdef void Py_DECREF(object o)

Stefan

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

Reply via email to