diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2016-05-12 12:25:46 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2016-05-12 12:25:46 -0600 |
commit | 383d800042769fc5aa159ff33988a3972e6d577f (patch) | |
tree | a89c48f17bbaaba1d46e55c7bdc17541e193382f /numpy | |
parent | e209a18b0121fca361e6cb186076c61de4b50f3a (diff) | |
parent | dbccef858cf2c1d169f3c99e3e1a7aa956ca4e01 (diff) | |
download | numpy-383d800042769fc5aa159ff33988a3972e6d577f.tar.gz |
Merge pull request #7627 from mattip/PyTuple-immutable
unify tup processing, move tup use to after all PyTuple_SetItem calls
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/descriptor.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 03a4654a0..7a1d44d08 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -533,8 +533,6 @@ _convert_from_array_descr(PyObject *obj, int align) goto fail; } dtypeflags |= (conv->flags & NPY_FROM_FIELDS); - tup = PyTuple_New((title == NULL ? 2 : 3)); - PyTuple_SET_ITEM(tup, 0, (PyObject *)conv); if (align) { int _align; @@ -544,10 +542,10 @@ _convert_from_array_descr(PyObject *obj, int align) } maxalign = PyArray_MAX(maxalign, _align); } + tup = PyTuple_New((title == NULL ? 2 : 3)); + PyTuple_SET_ITEM(tup, 0, (PyObject *)conv); PyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize)); - PyDict_SetItem(fields, name, tup); - /* * Title can be "meta-data". Only insert it * into the fields dictionary if it is a string @@ -556,6 +554,7 @@ _convert_from_array_descr(PyObject *obj, int align) if (title != NULL) { Py_INCREF(title); PyTuple_SET_ITEM(tup, 2, title); + PyDict_SetItem(fields, name, tup); #if defined(NPY_PY3K) if (PyUString_Check(title)) { #else @@ -570,6 +569,10 @@ _convert_from_array_descr(PyObject *obj, int align) PyDict_SetItem(fields, title, tup); } } + else { + PyDict_SetItem(fields, name, tup); + } + totalsize += conv->elsize; Py_DECREF(tup); } |