Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-14 Thread Chris Colbert
On Mon, Feb 14, 2011 at 1:49 AM, Greg Ewing 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 >

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-14 Thread Chris Colbert
On Mon, Feb 14, 2011 at 1:50 AM, Greg Ewing wrote: > Chris Colbert wrote: > >> changing the include definition to: >> >> cdef extern from "Python.h": >> int PyObject_GenericSetAttr(PyObject*, PyObject*, PyObject*) except -1 >> > > This suggests another possible workaround: > > > cdef extern f

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Greg Ewing
Chris Colbert wrote: changing the include definition to: cdef extern from "Python.h": int PyObject_GenericSetAttr(PyObject*, PyObject*, PyObject*) except -1 This suggests another possible workaround: cdef extern from "Python.h": int PyObject_GenericDelAttr "PyObject_GenericSetAttr"

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Greg Ewing
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

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Chris Colbert
changing the include definition to: cdef extern from "Python.h": int PyObject_GenericSetAttr(PyObject*, PyObject*, PyObject*) except -1 Seems to solve the problem, with the inconvenience of needing to explicitly cast to before calling it. However, the objects are no longer incref'd before c

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Chris Colbert
I should mention, that these PyObject_Generic* functions are being used from with __getattribute__, __setattr__, and __delattr__ methods. I should have added that context in the begining. On Sun, Feb 13, 2011 at 3:37 PM, Chris Colbert wrote: > The problem with delattr (and thus PyObject_DelAttr)

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Chris Colbert
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). Futher, calling PyObject_Generi

Re: [Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Greg Ewing
Chris Colbert wrote: I have cython file which is using PyObject_GenericSetAttr Now in my script I am using that function to generically delete an attribute by passing a NULL as the last value (this is proper way to trigger a generic delattr in the Python c-api) I would have thought the prope

[Cython] Bug in NULL handling introduced 0.14.1-1

2011-02-13 Thread Chris Colbert
I have cython file which is using PyObject_GenericSetAttr which is defined as follows in my pyx file: cdef extern from "Python.h": int PyObject_GenericSetAttr(object, object, object) except -1 Now in my script I am using that function to generically delete an attribute by passing a NULL as t