py/objint_mpz: Catch and reject @ and @= operating on big integers.
This will also catch / and /= when float support is disabled. Fixes issue #10544. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
d4a4cde42e
commit
d387ae3444
|
@ -296,8 +296,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
|
|||
mpz_pow_inpl(&res->mpz, zlhs, zrhs);
|
||||
break;
|
||||
|
||||
default: {
|
||||
assert(op == MP_BINARY_OP_DIVMOD);
|
||||
case MP_BINARY_OP_DIVMOD: {
|
||||
if (mpz_is_zero(zrhs)) {
|
||||
goto zero_division_error;
|
||||
}
|
||||
|
@ -306,6 +305,9 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
|
|||
mp_obj_t tuple[2] = {MP_OBJ_FROM_PTR(quo), MP_OBJ_FROM_PTR(res)};
|
||||
return mp_obj_new_tuple(2, tuple);
|
||||
}
|
||||
|
||||
default:
|
||||
return MP_OBJ_NULL; // op not supported
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(res);
|
||||
|
|
|
@ -7,6 +7,16 @@ try:
|
|||
except ValueError:
|
||||
print("ValueError")
|
||||
|
||||
try:
|
||||
i @ 0
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
i @= 0
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
len(i)
|
||||
except TypeError:
|
||||
|
|
Loading…
Reference in New Issue