-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
BUG: Fix strange behavior of infinite-step-size/underflow-case in arange #10263
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
Changes from 1 commit
671a224
825c681
4af6233
2607ad7
123da27
e2cc3e6
d4d2758
2827c66
0b60753
41cd4e1
12d020c
c5f589d
abc1686
514c8ec
d68afb3
2740bc9
04a85b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
PyObject_RichCompareBool
success check
- Loading branch information
Ther 8000 e are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3105,6 +3105,12 @@ _calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, i | |
} | ||
|
||
next_is_nonzero = PyObject_RichCompareBool(*next, zero, Py_NE); | ||
if (next_is_nonzero == -1) { | ||
Py_DECREF(zero); | ||
Py_DECREF(*next); | ||
*next = NULL; | ||
return -1; | ||
} | ||
val = PyNumber_TrueDivide(*next, step); | ||
Py_DECREF(*next); | ||
*next = NULL; | ||
|
@@ -3116,6 +3122,10 @@ _calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, i | |
|
||
val_is_zero = PyObject_RichCompareBool(val, zero, Py_EQ); | ||
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. Should be an 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. You need to check that this doesn't return -1, indicating an error occurred. Same above. |
||
Py_DECREF(zero); | ||
if (val_is_zero == -1) { | ||
Py_DECREF(val); | ||
return -1; | ||
} | ||
|
||
if (cmplx && PyComplex_Check(val)) { | ||
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. Trying to work out if this section needs a fix too, but I can't work out what this is even trying to do. 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. @eric-wieser Me too. I don't know why the complex case exists. This is none-sense as math. 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. See #10332. |
||
value = PyComplex_RealAsDouble(val); | ||
|
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.
Could use
PyObject_IsTrue
, but that might be worse on unusual typesThere 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.
@eric-wieser IMO,
PyObject_RichCompareBool
is better because this is clear what we do.