Raise error on power with negative number (#5143)

This commit is contained in:
kenny the :/ authored and GitHub committed 2024-01-12 21:16:53 +09:00
1 parent 28f0fa48a4
commit aaae566231
2 files changed
+1 -3

No files matched your search

-2
View File
@@ -236,8 +236,6 @@ class ComplexTest(unittest.TestCase):
for a, b in ZERO_DIVISION:
self.assertRaises(TypeError, divmod, a, b)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_pow(self):
self.assertAlmostEqual(pow(1+1j, 0+0j), 1.0)
self.assertAlmostEqual(pow(0+0j, 2+0j), 0.0)
+1 -1
View File
@@ -103,7 +103,7 @@ fn inner_div(v1: Complex64, v2: Complex64, vm: &VirtualMachine) -> PyResult<Comp
fn inner_pow(v1: Complex64, v2: Complex64, vm: &VirtualMachine) -> PyResult<Complex64> {
if v1.is_zero() {
return if v2.im != 0.0 {
return if v2.re < 0.0 || v2.im != 0.0 {
let msg = format!("{v1} cannot be raised to a negative or complex power");
Err(vm.new_zero_division_error(msg))
} else if v2.is_zero() {