summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-08-10 20:19:58 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-08-10 20:19:58 +0000
commit7bb36be47c5a2e1b1d51a556eec99bf741c2ff75 (patch)
tree1f62840d777576817710f0119aa8999ff551fbc5 /numpy/core/src
parent75c15c8c697eba656e333612821d44cdd46134fe (diff)
downloadnumpy-7bb36be47c5a2e1b1d51a556eec99bf741c2ff75.tar.gz
Fix ticket #674.
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/arrayobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 5b2390f03..fe789dee9 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -11145,7 +11145,8 @@ arraydescr_dealloc(PyArray_Descr *self)
/* we need to be careful about setting attributes because these
objects are pointed to by arrays that depend on them for interpreting
- data. Currently no attributes of dtype objects can be set.
+ data. Currently no attributes of data-type objects can be set
+ directly except names.
*/
static PyMemberDef arraydescr_members[] = {
{"type", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},
@@ -11403,9 +11404,11 @@ arraydescr_names_set(PyArray_Descr *self, PyObject *val)
key = PyTuple_GET_ITEM(self->names, i);
/* Borrowed reference to item */
item = PyDict_GetItem(self->fields, key);
+ Py_INCREF(item); /* Hold on to it even through DelItem */
new_key = PyTuple_GET_ITEM(new_names, i);
- PyDict_SetItem(self->fields, new_key, item);
PyDict_DelItem(self->fields, key);
+ PyDict_SetItem(self->fields, new_key, item);
+ Py_DECREF(item); /* self->fields now holds reference */
}
/* Replace names */