Skip to content
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

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

skirpichev
Copy link
Member

@skirpichev skirpichev commented Jun 8, 2024

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/

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().
@@ -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);
Copy link
Member Author

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.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@skirpichev
Copy link
Member Author

@vstinner, do you want a second opinion on this?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner vstinner merged commit 8a284e1 into python:main Sep 18, 2024
37 checks passed
@vstinner
Copy link
Member

Merged, thanks. I made minor edits on the commit message.

@skirpichev skirpichev deleted the complex_pow-errno-119771 branch September 18, 2024 08:46
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this pull request Sep 22, 2024
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().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants