[Numpy-svn] r8592 - in branches/1.5.x/numpy/core: src/multiarray tests

numpy-svn@scip... numpy-svn@scip...
Tue Aug 3 16:52:29 CDT 2010


Author: ptvirtan
Date: 2010-08-03 16:52:29 -0500 (Tue, 03 Aug 2010)
New Revision: 8592

Modified:
   branches/1.5.x/numpy/core/src/multiarray/item_selection.c
   branches/1.5.x/numpy/core/tests/test_regression.py
Log:
BUG: (backport r8572) core: fix refcount error in PyArray_Take (#939)

Modified: branches/1.5.x/numpy/core/src/multiarray/item_selection.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/item_selection.c	2010-08-03 21:52:04 UTC (rev 8591)
+++ branches/1.5.x/numpy/core/src/multiarray/item_selection.c	2010-08-03 21:52:29 UTC (rev 8592)
@@ -43,6 +43,7 @@
                                                          PyArray_INTP,
                                                          1, 0);
     if (indices == NULL) {
+        Py_XINCREF(ret);
         goto fail;
     }
     n = m = chunk = 1;

Modified: branches/1.5.x/numpy/core/tests/test_regression.py
===================================================================
--- branches/1.5.x/numpy/core/tests/test_regression.py	2010-08-03 21:52:04 UTC (rev 8591)
+++ branches/1.5.x/numpy/core/tests/test_regression.py	2010-08-03 21:52:29 UTC (rev 8592)
@@ -1358,5 +1358,19 @@
         y = np.add(x, x, x)
         assert_equal(id(x), id(y))
 
+    def test_take_refcount(self):
+        # ticket #939
+        a = np.arange(16, dtype=np.float)
+        a.shape = (4,4)
+        lut = np.ones((5 + 3, 4), np.float)
+        rgba = np.empty(shape=a.shape + (4,), dtype=lut.dtype)
+        c1 = sys.getrefcount(rgba)
+        try:
+            lut.take(a, axis=0, mode='clip', out=rgba)
+        except TypeError:
+            pass
+        c2 = sys.getrefcount(rgba)
+        assert_equal(c1, c2)
+
 if __name__ == "__main__":
     run_module_suite()



More information about the Numpy-svn mailing list