[SciPy-dev] Three cheers for Travis!

Travis Oliphant oliphant.travis at ieee.org
Wed Nov 30 14:38:29 EST 2005


Ed Schofield wrote:

>I have another couple of 0-dim array bugs to report (as a reward :D)
>
> >>> b = array(2)
> >>> b.argmax()
>0
> >>> b.argmin()
>Segmentation fault
>
>  
>
Thanks.  There may be a few more like these lurking.

The problem is that in the C-code, whenever the generic object interface
is used (like PyNumber_Subtract in this case) an array-scalar may get 
returned.  

Then, if that returned value is handed off to a subroutine that expects 
an array (like PyArray_ArgMax in this case), boom the problem occurs.

obj = PyArray_EnsureArray(obj)

can always be used in this case to get an actual ndarray object (it 
steals the reference for obj and so can be used as a wrapper around the 
generic Python C-API command).

Trying-to-teach-everyone-to-fish,

-Travis





More information about the SciPy-Dev mailing list