[Numpy-svn] r3445 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Nov 17 13:39:04 CST 2006


Author: oliphant
Date: 2006-11-17 13:39:02 -0600 (Fri, 17 Nov 2006)
New Revision: 3445

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Understand array's of ctypes types.

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-11-17 19:28:56 UTC (rev 3444)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-11-17 19:39:02 UTC (rev 3445)
@@ -50,8 +50,24 @@
         if (dtypedescr) {
                 ret = PyArray_DescrConverter(dtypedescr, &new);
                 Py_DECREF(dtypedescr);
-                if (ret == PY_SUCCEED) return new;
+                if (ret == PY_SUCCEED) {
+                        PyObject *length;
+                        length = PyObject_GetAttrString(obj, "_length_");
+                        PyErr_Clear();
+                        if (length) { /* derived type */
+                                PyObject *newtup;
+                                PyArray_Descr *derived;
+                                newtup = Py_BuildValue("NO", new, length);
+                                ret = PyArray_DescrConverter(newtup, &derived);
+                                Py_DECREF(newtup);
+                                if (ret == PY_SUCCEED) return derived;
+                                PyErr_Clear();
+                                return NULL;
+                        }
+                        return new;
+                }
                 PyErr_Clear();
+                return NULL;
         }
         /* Understand ctypes structures --
            bit-fields are not supported */



More information about the Numpy-svn mailing list