Skip to content

Commit

Permalink
Fix-up logic so that it is more readable.
Browse files Browse the repository at this point in the history
  • Loading branch information
teoliphant committed Jul 18, 2012
1 parent 7b8d30b commit 88cf94d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions numpy/core/src/multiarray/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ _array_find_python_scalar_type(PyObject *op)
}
}
else if (PyLong_Check(op)) {
/* if integer can fit into a longlong then return that*/
/* check to see if integer can fit into a longlong or ulonglong
and return that --- otherwise return object */
if ((PyLong_AsLongLong(op) == -1) && PyErr_Occurred()) {
PyErr_Clear();
if ((PyLong_AsUnsignedLongLong(op) == (unsigned long long) -1)
&& PyErr_Occurred()){
PyErr_Clear();
}
else {
return PyArray_DescrFromType(NPY_ULONGLONG);
}
return PyArray_DescrFromType(NPY_OBJECT);
}
else {
return PyArray_DescrFromType(NPY_LONGLONG);
}

if ((PyLong_AsUnsignedLongLong(op) == (unsigned long long) -1)
&& PyErr_Occurred()){
PyErr_Clear();
}
else {
return PyArray_DescrFromType(NPY_ULONGLONG);
}

return PyArray_DescrFromType(NPY_OBJECT);
}
return NULL;
}
Expand Down

0 comments on commit 88cf94d

Please sign in to comment.