[Numpy-discussion] python-numarray: _dotblas.dot calls spoils Py_None refcount

Achim Gaedke Achim.Gaedke at physik.tu-darmstadt.de
Mon Nov 20 06:13:42 CST 2006


Using the latest numarray distribution for debian testing I found a bug.
Executing the python script with python2.4 shows the decrement of None

import sys
import numarray

data1=numarray.arange(4096*2, type=numarray.Float32)
data2=numarray.arange(4096*2, type=numarray.Float32)

while True:
    print sys.getrefcount(None)
    val=numarray.dot(data1, data2)

I could trace this error down to the function NA_FromDimsStridesDescrAndData
in numarray/Src/libnumarray.ch .

The bug fix is:
--- python-numarray-1.5.2/Src/libnumarray.ch    2006-08-24
20:38:15.000000000 +0200
+++ /home/achim/libnumarray.ch  2006-11-19 21:14:52.000000000 +0100
@@ -877,6 +877,7 @@
                if (!buf) return NULL;
        } else {
                buf = Py_None;
+               Py_INCREF(buf);

        a = NA_NewAllFromBuffer( nd, dimensions, descr->type_num, buf,

I think it is still worth fixing this bug. I've sent that bug report
#399440 to Debian, too.

Yours, Achim

More information about the Numpy-discussion mailing list