From 2277f4182782a53f33cb3a4ae2bbd9dae987c5cc Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Wed, 18 Nov 2020 09:15:19 -0600 Subject: [PATCH] Actually fix negative check --- vm/src/builtins/int.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vm/src/builtins/int.rs b/vm/src/builtins/int.rs index ddf287f64..4bab115de 100644 --- a/vm/src/builtins/int.rs +++ b/vm/src/builtins/int.rs @@ -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), }