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

numpy-svn@scip... numpy-svn@scip...
Tue Feb 24 23:15:53 CST 2009


Author: oliphant
Date: 2009-02-24 23:15:47 -0600 (Tue, 24 Feb 2009)
New Revision: 6466

Modified:
   trunk/numpy/core/src/scalartypes.inc.src
   trunk/numpy/core/tests/test_regression.py
Log:
Fix void-scalar element access when data-type contains titles (meta-data).

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2009-02-24 20:53:10 UTC (rev 6465)
+++ trunk/numpy/core/src/scalartypes.inc.src	2009-02-25 05:15:47 UTC (rev 6466)
@@ -1448,9 +1448,11 @@
 static PyObject *
 voidtype_getfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
 {
-    PyObject *ret;
+    PyObject *ret, *newargs;
 
-    ret = gentype_generic_method((PyObject *)self, args, kwds, "getfield");
+    newargs = PyTuple_GetSlice(args, 0, 2);
+    ret = gentype_generic_method((PyObject *)self, newargs, kwds, "getfield");
+    Py_DECREF(newargs);
     if (!ret) {
         return ret;
     }

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2009-02-24 20:53:10 UTC (rev 6465)
+++ trunk/numpy/core/tests/test_regression.py	2009-02-25 05:15:47 UTC (rev 6466)
@@ -1220,5 +1220,13 @@
         n_after = len(gc.get_objects())
         assert n_before >= n_after, (n_before, n_after)
 
+    def test_void_scalar_with_titles(self, level=rlevel):
+        """No ticket"""
+        data = [('john', 4), ('mary', 5)]
+        dtype1 = [(('source:yy', 'name'), 'O'), (('source:xx', 'id'), int)]
+        arr = array(data, dtype=dtype1)
+        assert arr[0][0] == 'john'
+        assert arr[0][1] == 4
+
 if __name__ == "__main__":
     run_module_suite()



More information about the Numpy-svn mailing list