py: Catch all cases of integer (big and small) division by zero.

This commit is contained in:
Damien George
2015-10-01 22:48:48 +01:00
parent 2065373f67
commit e5635f4ab3
7 changed files with 45 additions and 1 deletions

View File

@@ -389,6 +389,9 @@ mp_obj_t mp_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_MODULO:
case MP_BINARY_OP_INPLACE_MODULO: {
if (rhs_val == 0) {
goto zero_division;
}
lhs_val = mp_small_int_modulo(lhs_val, rhs_val);
break;
}