[Numpy-svn] r3502 - in trunk/numpy: core/src lib/tests

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Jan 8 19:44:43 CST 2007


Author: oliphant
Date: 2007-01-08 19:44:40 -0600 (Mon, 08 Jan 2007)
New Revision: 3502

Modified:
   trunk/numpy/core/src/scalartypes.inc.src
   trunk/numpy/lib/tests/test_shape_base.py
Log:
Fix segfault in N.float64, ticket #412.

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2007-01-08 21:56:54 UTC (rev 3501)
+++ trunk/numpy/core/src/scalartypes.inc.src	2007-01-09 01:44:40 UTC (rev 3502)
@@ -1764,7 +1764,7 @@
         robj = PyArray_Return((PyArrayObject *)arr);
 
  finish:
-        if (robj->ob_type == type) return robj;
+        if ((robj==NULL) || (robj->ob_type == type)) return robj;
         /* Need to allocate new type and copy data-area over */
         if (type->tp_itemsize) {
                 itemsize = PyString_GET_SIZE(robj);

Modified: trunk/numpy/lib/tests/test_shape_base.py
===================================================================
--- trunk/numpy/lib/tests/test_shape_base.py	2007-01-08 21:56:54 UTC (rev 3501)
+++ trunk/numpy/lib/tests/test_shape_base.py	2007-01-09 01:44:40 UTC (rev 3502)
@@ -381,11 +381,12 @@
         assert_equal(tile(a,(1,2)), [[0,1,2,0,1,2]])
         assert_equal(tile(b, 2), [[1,2,1,2],[3,4,3,4]])
         assert_equal(tile(b,(2,1)),[[1,2],[3,4],[1,2],[3,4]])
-        assert_equal(tile(b,(2,2)),[[1,2,1,2],[3,4,3,4],[1,2,1,2],[3,4,3,4]])
+        assert_equal(tile(b,(2,2)),[[1,2,1,2],[3,4,3,4],
+                                    [1,2,1,2],[3,4,3,4]])
 
     def check_kroncompare(self):
         import numpy.random as nr
-	reps=[(2,),(1,2),(2,1),(2,2),(2,3,2),(3,2)]
+        reps=[(2,),(1,2),(2,1),(2,2),(2,3,2),(3,2)]
         shape=[(3,),(2,3),(3,4,3),(3,2,3),(4,3,2,4),(2,2)]
         for s in shape:
             b = nr.randint(0,10,size=s)
@@ -404,3 +405,4 @@
 
 if __name__ == "__main__":
     NumpyTest().run()
+ 



More information about the Numpy-svn mailing list