mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
a4d4c1ede2
commit
f7bb658124
3 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue