`x**y == 1/x**-y ` thus changing `/=` to `*=` by negating the exponent.
except OverflowError:
pass
+ # gh-113841: possible undefined division by 0 in _Py_c_pow()
+ x, y = 9j, 33j**3
+ with self.assertRaises(OverflowError):
+ x**y
+
def test_pow_with_small_integer_exponents(self):
# Check that small integer exponents are handled identically
# regardless of their type.
--- /dev/null
+Fix possible undefined behavior division by zero in :class:`complex`'s
+:c:func:`_Py_c_pow`.
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);