From c8b60f013b9d624a74ad502460f2bc7d00c39644 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 20 Apr 2015 13:29:31 +0000 Subject: py: Make viper codegen raise proper exception (ViperTypeError) on error. This fixes a long standing problem that viper code generation gave terrible error messages, and actually no errors on pyboard where assertions are disabled. Now all compile-time errors are raised as proper Python exceptions, and are of type ViperTypeError. Addresses issue #940. --- py/objexcept.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'py/objexcept.c') diff --git a/py/objexcept.c b/py/objexcept.c index 4623e7318..6c108d99c 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -252,6 +252,10 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) */ //MP_DEFINE_EXCEPTION(SystemError, Exception) MP_DEFINE_EXCEPTION(TypeError, Exception) +#if MICROPY_EMIT_NATIVE + MP_DEFINE_EXCEPTION_BASE(TypeError) + MP_DEFINE_EXCEPTION(ViperTypeError, TypeError) +#endif MP_DEFINE_EXCEPTION(ValueError, Exception) #if MICROPY_PY_BUILTINS_STR_UNICODE MP_DEFINE_EXCEPTION_BASE(ValueError) -- cgit v1.2.3