gh-113841: fix possible undefined division by 0 in _Py_c_pow() (GH-127211)

`x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.
This commit is contained in:
Sergey B Kirpichev 2024-11-24 10:37:37 +03:00 committed by GitHub
parent a4d4c1ede2
commit f7bb658124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -168,7 +168,7 @@ _Py_c_pow(Py_complex a, Py_complex b)
at = atan2(a.imag, a.real);
phase = at*b.real;
if (b.imag != 0.0) {
len /= exp(at*b.imag);
len *= exp(-at*b.imag);
phase += b.imag*log(vabs);
}
r.real = len*cos(phase);