From a55988a547011c04978a1661325062397ef74110 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 25 Mar 2018 16:01:06 -0500 Subject: Fix assertion failure in mpz_divmod_inpl .. turning this from an assertion failure into an exception: pow(1,1,0) --- py/objint_mpz.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'py/objint_mpz.c') diff --git a/py/objint_mpz.c b/py/objint_mpz.c index 7b5cb0b9d..808fae6e4 100644 --- a/py/objint_mpz.c +++ b/py/objint_mpz.c @@ -343,6 +343,10 @@ mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus) { mpz_t *rhs = mp_mpz_for_int(exponent, &r_temp); mpz_t *mod = mp_mpz_for_int(modulus, &m_temp); + if (mpz_is_zero(mod)) { + mp_raise_msg(&mp_type_ValueError, "pow() 3rd argument cannot be 0"); + } + mpz_pow3_inpl(&(res_p->mpz), lhs, rhs, mod); if (lhs == &l_temp) { mpz_deinit(lhs); } -- cgit v1.2.3