[Numpy-svn] r8159 - trunk/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 12:11:39 CST 2010


Author: ptvirtan
Date: 2010-02-20 12:11:38 -0600 (Sat, 20 Feb 2010)
New Revision: 8159

Modified:
   trunk/numpy/core/src/multiarray/ctors.c
Log:
3K: core: allow unicode type strings in __array_interface__ since we allow those also in dtypes

Modified: trunk/numpy/core/src/multiarray/ctors.c
===================================================================
--- trunk/numpy/core/src/multiarray/ctors.c	2010-02-20 18:11:21 UTC (rev 8158)
+++ trunk/numpy/core/src/multiarray/ctors.c	2010-02-20 18:11:38 UTC (rev 8159)
@@ -2260,11 +2260,22 @@
         }
     }
     attr = tstr;
-    if (!PyString_Check(attr)) {
+#if defined(NPY_PY3K)
+    if (PyUnicode_Check(tstr)) {
+        /* Allow unicode type strings */
+        attr = PyUnicode_AsASCIIString(tstr);
+    }
+#endif
+    if (!PyBytes_Check(attr)) {
         PyErr_SetString(PyExc_TypeError, "typestr must be a string");
         goto fail;
     }
     type = _array_typedescr_fromstr(PyString_AS_STRING(attr));
+#if defined(NPY_PY3K)
+    if (attr != tstr) {
+        Py_DECREF(attr);
+    }
+#endif
     if (type == NULL) {
         goto fail;
     }



More information about the Numpy-svn mailing list