Skip to content

gh-156693: correct complex powers with infinite bases - #156694

Open
skirpichev wants to merge 2 commits into
python:mainfrom
skirpichev:fix-cpow-overflows/156693
Open

gh-156693: correct complex powers with infinite bases#156694
skirpichev wants to merge 2 commits into
python:mainfrom
skirpichev:fix-cpow-overflows/156693

Conversation

@skirpichev

@skirpichev skirpichev commented Aug 31, 2026

Copy link
Copy Markdown
Member

Now we raise OverflowError's only if infinite result (i.e. cmath.isinf(result) is True) come from finite input. As proposed in issue #156145, we don't use platforms errno to manage exceptions anymore.

This patch also adds private API functions _Py_c_isnan(), _Py_c_isinf() and _Py_c_isfinite().

Now we raise OverflowError's only if infinite result (i.e.
cmath.isinf(result) is True) come from finite input.  As proposed in
issue python#156145, we don't use platforms `errno` to manage exceptions
anymore.

This patch also adds private API functions `_Py_c_isnan()`,
`_Py_c_isinf()` and `_Py_c_isfinite()`.
@skirpichev

Copy link
Copy Markdown
Member Author

CC @serhiy-storchaka

I think this will be less controversial change vs #118000 or #124243. Anyway, I think it worth for a dedicated commit.

@skirpichev

Copy link
Copy Markdown
Member Author

CC @hpkfft

Comment thread Objects/complexobject.c
Comment on lines 342 to 351
@@ -332,8 +349,25 @@ _Py_c_pow(Py_complex a, Py_complex b)
}
r.real = len*cos(phase);
r.imag = len*sin(phase);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

BTW, this generic code should handle special cases above correctly. Maybe we should drop them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant