]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-120010: Fix invalid (nan+nanj) results in _Py_c_prod() (GH-120287)
authorSergey B Kirpichev <skirpichev@gmail.com>
Fri, 6 Dec 2024 10:28:32 +0000 (13:28 +0300)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2024 10:28:32 +0000 (12:28 +0200)
commit8b7c194c7bf7e547e4f6317528f0dcb9344c18c7
tree8f38c98b9e4b017b10365a9033d4816810634249
parente991ac8f2037d78140e417cc9a9486223eb3e786
gh-120010: Fix invalid (nan+nanj) results in _Py_c_prod() (GH-120287)

In some cases, previously computed as (nan+nanj), we could recover
meaningful component values in the result, see e.g. the C11, Annex
G.5.1, routine _Cmultd():

>>> z = 1e300+1j
>>> z*(nan+infj)  # was (nan+nanj)
(-inf+infj)

That also fix some complex powers for small integer exponents, computed
with optimized algorithm (by squaring):

>>> z**5  # was (nan+nanj)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    z**5
    ~^^~
OverflowError: complex exponentiation
Lib/test/test_complex.py
Misc/NEWS.d/next/Core_and_Builtins/2024-06-04-08-26-25.gh-issue-120010._z-AWz.rst [new file with mode: 0644]
Objects/complexobject.c