summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2010-02-12 01:18:19 +0000
committerTravis Oliphant <oliphant@enthought.com>2010-02-12 01:18:19 +0000
commit9632b5431590ff26371efd259f199e4d70306ebb (patch)
treea3abaab8610beab66b908b988143e4cbaeef8729
parent8dbea178460b59169a645076e7dfd122409e1382 (diff)
downloadnumpy-9632b5431590ff26371efd259f199e4d70306ebb.tar.gz
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.
-rw-r--r--numpy/core/src/multiarray/descriptor.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index 3c67a6b32..fefc1bb28 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -1641,8 +1641,18 @@ arraydescr_reduce(PyArray_Descr *self, PyObject *NPY_UNUSED(args))
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 @@ arraydescr_reduce(PyArray_Descr *self, PyObject *NPY_UNUSED(args))
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;