Hi, note that this is a question for the cython-users mailing list.

Robert Kern, 15.07.2010 19:38:
> What are the recommendations for the use of the "object" type versus "PyObject
> *"? Ondrej pointed out a potential bug in my line_profiler package:
>
> http://github.com/certik/line_profiler/commit/dc3ad198f8a810d34da5da71ffccf01c5e05a161
>
> I have a cdef function that serves as the callback for the PyEval_SetTrace()
> functionality. It has a PyObject* argument that is sometimes NULL. This 
> argument
> happens to be unused. In the version of Cython I originally developed
> line_profile under , no code referenced this argument. In the development
> version of Cython that Ondrej used to compile line_profiler, a Py_INCREF is
> apparently generated. When the argument is NULL, this obviously fails.
>
> Is this intentional? Should "object" be avoided when the argument could 
> possibly
> be NULL? Or should the generated code use Py_XINCREF/Py_XDECREF instead to 
> avoid
> failure?

In Cython, object and PyObject* are not compatible. The first is an 
automatically ref-counted object, whereas the second is a plain pointer. 
For an argument that can be NULL, you cannot use object.

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

Reply via email to