diff options
| author | Jeff Epler <jepler@unpythonic.net> | 2018-03-25 16:01:06 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2018-03-29 06:42:10 -0500 |
| commit | a55988a547011c04978a1661325062397ef74110 (patch) | |
| tree | 2b9cee87e038cfd525c4dfc6c3932e44683f73af /py | |
| parent | 1eba5804434a8acc182c23aadf5b5a5dcbe901fa (diff) | |
Fix assertion failure in mpz_divmod_inpl
.. turning this from an assertion failure into an exception:
pow(1,1,0)
Diffstat (limited to 'py')
| -rw-r--r-- | py/objint_mpz.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); } |
