From: <lu...@o2...> - 2010-06-03 22:20:15
|
Daniel Wheeler <dan...@gm...> writes: > Can I do a 1.1.1 release? Any objections? Find() method is quite > important for fipy right now. Could you apply my old patch (2009-12-09) before the release: ll_mat: fix raising IndexError for invalid indices - ID: 2911619 http://sourceforge.net/tracker/?func=detail&aid=2911619&group_id=101403&atid=629638 The patch has unclear description (better below) and probably will fail (another of my patches already applied is changing the same lines) -- I can update the patch if you are willing to apply it. Better description: >>> from pysparse.spmatrix import ll_mat >>> a = ll_mat(3,3) >>> a[0,0] 0.0 >>> print a[0] None >>> print a[0,0,0] None But "a[0]" and "a[0,0,0]" should raise IndexError and that is what happens in the C function, but the function returns None instead of NULL and that is why the exception is not actually raised. > > On Thu, Jun 3, 2010 at 10:10 AM, Dominique Orban > <dom...@gm...> wrote: >> Yes please. Thanks for finding this bug! >> >> On Thu, Jun 3, 2010 at 3:47 PM, Daniel Wheeler >> <dan...@gm...> wrote: >>> Shall I do this on the version 1.1 branch and trunk? >>> >>> 2010/6/3 Dominique Orban <dom...@gm...>: >>>> 2010/6/3 Łukasz Pankowski <lu...@o2...>: >>>>> Daniel Wheeler <dan...@gm...> writes: >>>>> >>>>>> It seems that the find() method (lin 2986 in in Src/ll_mat.c) has a >>>>>> memory leak. Calling PyDECREF on a_row, a_col and a_val fixes this >>>>>> issue. I propose the following change: >>>>> >>>>> I propose simpler (`N' is like `O' but without PyINCREF, details below): >>>>> >>>>> $ git diff >>>>> diff --git a/Src/ll_mat.c b/Src/ll_mat.c >>>>> index 230829a..1adee2f 100644 >>>>> --- a/Src/ll_mat.c >>>>> +++ b/Src/ll_mat.c >>>>> @@ -3014,7 +3014,7 @@ static PyObject *LLMat_Find( LLMatObject *self, PyObject *args ) { >>>>> } >>>>> } >>>>> >>>>> - return Py_BuildValue( "OOO", >>>>> + return Py_BuildValue( "NNN", >>>>> PyArray_Return( a_val ), >>>>> PyArray_Return( a_row ), >>>>> PyArray_Return( a_col ) ); >>>>> >>>>> >>>>> from File: python2.5-api.info, Node: Parsing arguments and building values >>>>> >>>>> ``N' (object) {[PyObject * }]' >>>>> Same as `O', except it doesn't increment the reference count >>>>> on the object. Useful when the object is created by a call >>>>> to an object constructor in the argument list. >>>> >>>> Thanks. I fixed it in the new-setup branch as well. >>>> >>>> -- >>>> Dominique >>>> >>> >>> >>> >>> -- >>> Daniel Wheeler >>> >> >> >> >> -- >> Dominique >> |