Merge pull request #1865 from terriko/mpy_error
Make status light flash blue for incompatible mpy (fixes #1369)
This commit is contained in:
commit
9ce042ad07
|
@ -722,6 +722,7 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MpyError), MP_ROM_PTR(&mp_type_MpyError) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) },
|
||||
|
|
1
py/obj.h
1
py/obj.h
|
@ -599,6 +599,7 @@ extern const mp_obj_type_t mp_type_ReloadException;
|
|||
extern const mp_obj_type_t mp_type_KeyError;
|
||||
extern const mp_obj_type_t mp_type_LookupError;
|
||||
extern const mp_obj_type_t mp_type_MemoryError;
|
||||
extern const mp_obj_type_t mp_type_MpyError;
|
||||
extern const mp_obj_type_t mp_type_NameError;
|
||||
extern const mp_obj_type_t mp_type_NotImplementedError;
|
||||
extern const mp_obj_type_t mp_type_OSError;
|
||||
|
|
|
@ -311,6 +311,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
|
|||
MP_DEFINE_EXCEPTION(UnicodeError, ValueError)
|
||||
//TODO: Implement more UnicodeError subclasses which take arguments
|
||||
#endif
|
||||
MP_DEFINE_EXCEPTION(MpyError, ValueError)
|
||||
/*
|
||||
MP_DEFINE_EXCEPTION(Warning, Exception)
|
||||
MP_DEFINE_EXCEPTION(DeprecationWarning, Warning)
|
||||
|
|
|
@ -220,7 +220,7 @@ mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader) {
|
|||
|| header[1] != MPY_VERSION
|
||||
|| header[2] != MPY_FEATURE_FLAGS
|
||||
|| header[3] > mp_small_int_bits()) {
|
||||
mp_raise_ValueError(translate("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info."));
|
||||
mp_raise_MpyError(translate("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info."));
|
||||
}
|
||||
mp_raw_code_t *rc = load_raw_code(reader);
|
||||
reader->close(reader->data);
|
||||
|
|
|
@ -1598,6 +1598,10 @@ NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt,
|
|||
nlr_raise(exception);
|
||||
}
|
||||
|
||||
NORETURN void mp_raise_MpyError(const compressed_string_t *msg) {
|
||||
mp_raise_msg(&mp_type_MpyError, msg);
|
||||
}
|
||||
|
||||
#if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK
|
||||
NORETURN void mp_raise_recursion_depth(void) {
|
||||
mp_raise_RuntimeError(translate("maximum recursion depth exceeded"));
|
||||
|
|
|
@ -163,6 +163,7 @@ NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
|
|||
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
|
||||
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_MpyError(const compressed_string_t *msg);
|
||||
NORETURN void mp_raise_recursion_depth(void);
|
||||
|
||||
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
|
||||
|
|
|
@ -31,4 +31,5 @@
|
|||
#define NAME_ERROR WHITE
|
||||
#define OS_ERROR ORANGE
|
||||
#define VALUE_ERROR PURPLE
|
||||
#define MPY_ERROR BLUE
|
||||
#define OTHER_ERROR YELLOW
|
||||
|
|
|
@ -247,6 +247,8 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
|
|||
status->exception_color = OS_ERROR;
|
||||
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_ValueError)) {
|
||||
status->exception_color = VALUE_ERROR;
|
||||
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_MpyError)) {
|
||||
status->exception_color = MPY_ERROR;
|
||||
} else {
|
||||
status->exception_color = OTHER_ERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue