Skip to content

Commit e753d91

Browse files
committed
py: Raise exception for unimplemented byte codes.
1 parent b7ffdcc commit e753d91

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

py/vm.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,10 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
639639
obj1 = TOP();
640640
SET_TOP(mp_obj_new_slice(obj1, obj2, NULL));
641641
} else {
642-
printf("3-argument slice is not supported\n");
643-
assert(0);
642+
obj1 = mp_obj_new_exception_msg(&mp_type_NotImplementedError, "3-argument slice is not supported");
643+
nlr_pop();
644+
fastn[0] = obj1;
645+
return MP_VM_RETURN_EXCEPTION;
644646
}
645647
break;
646648
#endif
@@ -833,9 +835,10 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
833835

834836
default:
835837
printf("code %p, byte code 0x%02x not implemented\n", ip, op);
836-
assert(0);
838+
obj1 = mp_obj_new_exception_msg(&mp_type_NotImplementedError, "byte code not implemented");
837839
nlr_pop();
838-
return MP_VM_RETURN_NORMAL;
840+
fastn[0] = obj1;
841+
return MP_VM_RETURN_EXCEPTION;
839842
}
840843
}
841844

0 commit comments

Comments
 (0)