[Numpy-svn] r8298 - in trunk/numpy/core: src/multiarray tests

numpy-svn@scip... numpy-svn@scip...
Sun Mar 21 17:30:39 CDT 2010


Author: ptvirtan
Date: 2010-03-21 17:30:39 -0500 (Sun, 21 Mar 2010)
New Revision: 8298

Modified:
   trunk/numpy/core/src/multiarray/ctors.c
   trunk/numpy/core/tests/test_regression.py
Log:
BUG: core: fix #1436 by reverting r8144

r8144 "ENH: core: make PyArray_FromAny error message more clear"
is a cosmetic fix -- a revised one could be committed later on in, but
let's have this one bug fixed quick.

Also, add a regression test.

Modified: trunk/numpy/core/src/multiarray/ctors.c
===================================================================
--- trunk/numpy/core/src/multiarray/ctors.c	2010-03-18 21:43:07 UTC (rev 8297)
+++ trunk/numpy/core/src/multiarray/ctors.c	2010-03-21 22:30:39 UTC (rev 8298)
@@ -1820,27 +1820,14 @@
                  * If object was explicitly requested,
                  * then try nested list object array creation
                  */
+                PyErr_Clear();
                 if (isobject) {
-                    PyErr_Clear();
                     Py_INCREF(newtype);
                     r = ObjectArray_FromNestedList
                         (op, newtype, flags & FORTRAN);
                     seq = TRUE;
                     Py_DECREF(newtype);
                 }
-                else if ((newtype->type_num == PyArray_STRING ||
-                          newtype->type_num == PyArray_UNICODE)
-                         && PySequence_Size(op) > 0)
-                {
-                    /* It is not possible to set a sequence into
-                     * a string/unicode 0-d array item -- bail out early
-                     * so that the error message is more clear.
-                     */
-                    seq = TRUE;
-                }
-                else {
-                    PyErr_Clear();
-                }
             }
             else {
                 seq = TRUE;

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2010-03-18 21:43:07 UTC (rev 8297)
+++ trunk/numpy/core/tests/test_regression.py	2010-03-21 22:30:39 UTC (rev 8298)
@@ -1281,5 +1281,9 @@
             assert isinstance(path, (str, unicode))
             assert path != ''
 
+    def test_0d_string_scalar(self):
+        # Bug #1436; the following should succeed
+        np.asarray('x', '>c')
+
 if __name__ == "__main__":
     run_module_suite()



More information about the Numpy-svn mailing list