mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Actually fix negative check
This commit is contained in:
1 parent
b97aa409ef
commit
2277f41827
1 file changed
+7
-4
@@ -425,10 +425,13 @@ impl PyInt {
|
||||
if modulus.is_zero() {
|
||||
return Err(vm.new_value_error("pow() 3rd argument cannot be 0".to_owned()));
|
||||
}
|
||||
if modulus.is_negative() {
|
||||
return Err(vm.new_not_implemented_error("modular inverses".to_owned()));
|
||||
}
|
||||
self.general_op(other, |a, b| Ok(vm.ctx.new_int(a.modpow(b, modulus))), vm)
|
||||
self.general_op(other, |a, b| {
|
||||
if b.is_negative() {
|
||||
Err(vm.new_not_implemented_error("modular inverses".to_owned()))
|
||||
} else {
|
||||
Ok(vm.ctx.new_int(a.modpow(b, modulus)))
|
||||
}
|
||||
}, vm)
|
||||
}
|
||||
None => self.general_op(other, |a, b| inner_pow(a, b, vm), vm),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user