-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: ticket #2028: ... #356
Changes from 4 commits
6966bdc
3d31029
681bceb
120c6bd
78f6672
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,17 @@ _array_find_python_scalar_type(PyObject *op) | |
/* if integer can fit into a longlong then return that*/ | ||
if ((PyLong_AsLongLong(op) == -1) && PyErr_Occurred()) { | ||
PyErr_Clear(); | ||
if((PyLong_AsUnsignedLongLong(op) == -1) && PyErr_Occurred()){ | ||
PyErr_Clear(); | ||
} | ||
else { | ||
return PyArray_DescrFromType(NPY_ULONGLONG); | ||
} | ||
return PyArray_DescrFromType(NPY_OBJECT); | ||
} | ||
return PyArray_DescrFromType(NPY_LONGLONG); | ||
else { | ||
return PyArray_DescrFromType(NPY_LONGLONG); | ||
} | ||
} | ||
return NULL; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation on this does not look quite right. Could you check alignment? Otherwise, this seems like a useful patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're tabs instead of spaces. Eric, you need to fix your editor. Also, else like so:
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close ;) These lines need an extra indent. Also, checking an unsigned integer for a negative value should raise a compile warning at minimum. I think the value checks need to be done away with in any case as the documentation doesn't indicate any special return value as a possible error code, but perhaps that is a defect of the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I checked the [http://docs.python.org/c-api/long.html](Python 2.7) documentation and -1 indeed indicates a possible error, however the docs also show a cast for the unsigned types, i.e.,
(unsigned long long) -1
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like i am missing what it is that makes these lines need more indents, can you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second
if
is part the body of the firstif
.