[Numpy-svn] r5426 - branches/1.1.x/numpy/core/src
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue Jul 15 23:10:55 EDT 2008
Author: charris
Date: 2008-07-15 22:10:52 -0500 (Tue, 15 Jul 2008)
New Revision: 5426
Modified:
branches/1.1.x/numpy/core/src/arraytypes.inc.src
Log:
Backport r5392 by copying function PyArray_DescrFromType from trunk.
Modified: branches/1.1.x/numpy/core/src/arraytypes.inc.src
===================================================================
--- branches/1.1.x/numpy/core/src/arraytypes.inc.src 2008-07-16 03:07:22 UTC (rev 5425)
+++ branches/1.1.x/numpy/core/src/arraytypes.inc.src 2008-07-16 03:10:52 UTC (rev 5426)
@@ -2476,46 +2476,56 @@
static PyArray_Descr *
PyArray_DescrFromType(int type)
{
- PyArray_Descr *ret=NULL;
+ PyArray_Descr *ret = NULL;
if (type < PyArray_NTYPES) {
ret = _builtin_descrs[type];
}
else if (type == PyArray_NOTYPE) {
- /* This needs to not raise an error so
- that PyArray_DescrFromType(PyArray_NOTYPE)
- works for backwards-compatible C-API
+ /*
+ * This needs to not raise an error so
+ * that PyArray_DescrFromType(PyArray_NOTYPE)
+ * works for backwards-compatible C-API
*/
return NULL;
}
- else if ((type == PyArray_CHAR) || \
- (type == PyArray_CHARLTR)) {
+ else if ((type == PyArray_CHAR) || (type == PyArray_CHARLTR)) {
ret = PyArray_DescrNew(_builtin_descrs[PyArray_STRING]);
+
+ if (ret == NULL) {
+ return NULL;
+ }
ret->elsize = 1;
ret->type = PyArray_CHARLTR;
return ret;
}
- else if PyTypeNum_ISUSERDEF(type) {
- ret = userdescrs[type-PyArray_USERDEF];
+ else if (PyTypeNum_ISUSERDEF(type)) {
+ ret = userdescrs[type - PyArray_USERDEF];
}
else {
- int num=PyArray_NTYPES;
- if (type < _MAX_LETTER)
+ int num = PyArray_NTYPES;
+ if (type < _MAX_LETTER) {
num = (int) _letter_to_num[type];
- if (num >= PyArray_NTYPES)
+ }
+ if (num >= PyArray_NTYPES) {
ret = NULL;
- else
+ }
+ else {
ret = _builtin_descrs[num];
+ }
}
- if (ret==NULL) {
+ if (ret == NULL) {
PyErr_SetString(PyExc_ValueError,
"Invalid data-type for array");
}
- else Py_INCREF(ret);
+ else {
+ Py_INCREF(ret);
+ }
return ret;
}
+
static int
set_typeinfo(PyObject *dict)
{
More information about the Numpy-svn
mailing list