From 88cf94d5ddc1c42e2ff078dc4fbb3c626efedae3 Mon Sep 17 00:00:00 2001 From: "Travis E. Oliphant" Date: Tue, 17 Jul 2012 21:55:08 -0500 Subject: Fix-up logic so that it is more readable. --- numpy/core/src/multiarray/common.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'numpy') diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c index 123ec62e7..5ab8f92bc 100644 --- a/numpy/core/src/multiarray/common.c +++ b/numpy/core/src/multiarray/common.c @@ -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; } -- cgit v1.2.1