Skip to content

Commit 8bcb986

Browse files
committed
py: Don't assert but go to unsupported_op in mp_binary_op for small int.
1 parent 5cd0b22 commit 8bcb986

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

py/runtime.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ mp_obj_t mp_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
365365
case MP_BINARY_OP_LESS_EQUAL: return MP_BOOL(lhs_val <= rhs_val); break;
366366
case MP_BINARY_OP_MORE_EQUAL: return MP_BOOL(lhs_val >= rhs_val); break;
367367

368-
default: assert(0);
368+
default:
369+
goto unsupported_op;
369370
}
370371
// TODO: We just should make mp_obj_new_int() inline and use that
371372
if (MP_OBJ_FITS_SMALL_INT(lhs_val)) {
@@ -437,9 +438,7 @@ mp_obj_t mp_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
437438
// TODO implement dispatch for reverse binary ops
438439

439440
// TODO specify in error message what the operator is
440-
#if MICROPY_ENABLE_FLOAT
441441
unsupported_op:
442-
#endif
443442
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
444443
"unsupported operand types for binary operator: '%s', '%s'",
445444
mp_obj_get_type_str(lhs), mp_obj_get_type_str(rhs)));

0 commit comments

Comments
 (0)