-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-119771: adjust errno on overflows in _Py_c_pow() #120256
Conversation
Before we did this in complex_pow() and behaviour of the public C API function ``_Py_c_pow()`` was different from the pure-python pow().
Co-authored-by: Victor Stinner <[email protected]>
@@ -546,12 +548,12 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z) | |||
// a faster and more accurate algorithm. | |||
if (b.imag == 0.0 && b.real == floor(b.real) && fabs(b.real) <= 100.0) { | |||
p = c_powi(a, (long)b.real); | |||
_Py_ADJUST_ERANGE2(p.real, p.imag); |
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.
That might be moved to c_powi()
, but that will make patch slightly larger. I think this is fine, as c_powi()
is not a part of C API.
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.
LGTM
@vstinner, do you want a second opinion on this? |
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.
LGTM
Merged, thanks. I made minor edits on the commit message. |
Before we did this in complex_pow() and behavior of the public C API function _Py_c_pow() was different from the pure-python pow().
Before we did this in complex_pow() and behaviour of the public C API function
_Py_c_pow()
was different from the pure-python pow().📚 Documentation preview 📚: https://cpython-previews--120256.org.readthedocs.build/