[Cython] Bug in NULL handling introduced 0.14.1-1

Chris Colbert sccolbert at gmail.com
Mon Feb 14 15:13:51 CET 2011

On Mon, Feb 14, 2011 at 1:49 AM, Greg Ewing <greg.ewing at canterbury.ac.nz>wrote:

> Chris Colbert wrote:
>> The problem with delattr (and thus PyObject_DelAttr) arises when you
>> define a __delattr__ method on your class. There is not easy way to then
>> call back into the "normal" python delattr semantics, except by doing
>> object.__delattr__ (which is not optimized by Cython).
> Hmmm, perhaps it should be? And similarly for all the other type
> slots.
>  I would argue that there should be at least some way to pass a NULL
>> pointer in Cython where a PyObject* is expected.
> The trouble is that supporting this in general both safely and
> efficiently would require keeping track of which object references
> are allowed to be NULL. Could be done, but might require quite a
> lot of work.
> Maybe something more limited could be done such as allowing
> a literal NULL to be passed to a function argument that is
> specially marked as permitting this.
I had the same kind of thoughts. Perhaps something like:

cdef extern from "Python.h":
    PyObject_GenericSetAttr(object, object, object or NULL)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20110214/b3cbe970/attachment.html>

More information about the cython-devel mailing list