Hi,

Lisandro Dalcin wrote:
> Please look at 'Objects/classobject.c' , and tell me what do you think
> about this patch. This guy was causing the segfaults with Cython's
> 'classmethod' implementation
> 
> Index: Objects/classobject.c
> ===================================================================
> --- Objects/classobject.c     (revision 63598)
> +++ Objects/classobject.c     (working copy)
> @@ -502,7 +502,7 @@
>  instancemethod_descr_get(PyObject *descr, PyObject *obj, PyObject *type) {
>       register PyObject *func = PyInstanceMethod_GET_FUNCTION(descr);
>       if (obj == NULL)
> -             return func;
> +             return Py_INCREF(func), func;
>       else
>               return PyMethod_New(func, obj);
>  }

To comment on this, I would have to look through all occurrences of
instancemethod_descr_get() and see if this corresponds to the way the result
is handled...

... but given that PyMethod_New() returns a new reference also, I would
suspect that the above is the right thing to do - although

    Py_INCREF(func);
    return func;

looks better to me... :)

Thanks for looking through all this, BTW. Should I file the bug report or do
you want to do it yourself?

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

Reply via email to