[Numpy-svn] r8108 - branches/1.4.x/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Thu Feb 11 19:18:19 CST 2010


Author: oliphant
Date: 2010-02-11 19:18:19 -0600 (Thu, 11 Feb 2010)
New Revision: 8108

Modified:
   branches/1.4.x/numpy/core/src/multiarray/descriptor.c
Log:
Fix 1.4.x branch so that it also does not add the metadata info to the dtype pickle unless it has to.  This will allow 1.4.x pickles to be compatible with 1.3.x pickles.

Modified: branches/1.4.x/numpy/core/src/multiarray/descriptor.c
===================================================================
--- branches/1.4.x/numpy/core/src/multiarray/descriptor.c	2010-02-12 00:37:17 UTC (rev 8107)
+++ branches/1.4.x/numpy/core/src/multiarray/descriptor.c	2010-02-12 01:18:19 UTC (rev 8108)
@@ -1641,8 +1641,18 @@
             endian = '>';
         }
     }
-    state = PyTuple_New(9);
-    PyTuple_SET_ITEM(state, 0, PyInt_FromLong(version));
+
+    if (self->metadata) {
+        state = PyTuple_New(9);
+        PyTuple_SET_ITEM(state, 0, PyInt_FromLong(version));
+        Py_INCREF(self->metadata);
+        PyTuple_SET_ITEM(state, 8, self->metadata);
+    }
+    else {
+        state = PyTuple_New(8);
+        PyTuple_SET_ITEM(state, 0, PyInt_FromLong(3));
+    }
+
     PyTuple_SET_ITEM(state, 1, PyString_FromFormat("%c", endian));
     PyTuple_SET_ITEM(state, 2, arraydescr_subdescr_get(self));
     if (self->names) {
@@ -1670,14 +1680,6 @@
     PyTuple_SET_ITEM(state, 5, PyInt_FromLong(elsize));
     PyTuple_SET_ITEM(state, 6, PyInt_FromLong(alignment));
     PyTuple_SET_ITEM(state, 7, PyInt_FromLong(self->hasobject));
-    if (self->metadata) {
-        Py_INCREF(self->metadata);
-        PyTuple_SET_ITEM(state, 8, self->metadata);
-    }
-    else {
-        PyTuple_SET_ITEM(state, 8, Py_None);
-        Py_INCREF(Py_None);
-    }
 
     PyTuple_SET_ITEM(ret, 2, state);
     return ret;



More information about the Numpy-svn mailing list