From e7a478204a984f9f79a99700375d961be6d28a96 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 22 Oct 2014 19:42:55 +0100 Subject: [PATCH] py: Remove unused and unneeded SystemError exception. It's purpose is for internal errors that are not catastrophic (ie not as bad as RuntimeError). Since we don't use it, we don't need it. --- py/builtintables.c | 1 - py/obj.h | 1 - py/objexcept.c | 2 +- py/qstrdefs.h | 1 - tests/basics/exceptpoly.py | 16 ++++++++-------- tests/micropython/viper_misc.py | 4 ++-- tests/micropython/viper_misc.py.exp | 2 +- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/py/builtintables.c b/py/builtintables.c index b67ef05169..0e5daf6d8d 100644 --- a/py/builtintables.c +++ b/py/builtintables.c @@ -136,7 +136,6 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_RuntimeError), (mp_obj_t)&mp_type_RuntimeError }, { MP_OBJ_NEW_QSTR(MP_QSTR_StopIteration), (mp_obj_t)&mp_type_StopIteration }, { MP_OBJ_NEW_QSTR(MP_QSTR_SyntaxError), (mp_obj_t)&mp_type_SyntaxError }, - { MP_OBJ_NEW_QSTR(MP_QSTR_SystemError), (mp_obj_t)&mp_type_SystemError }, { MP_OBJ_NEW_QSTR(MP_QSTR_SystemExit), (mp_obj_t)&mp_type_SystemExit }, { MP_OBJ_NEW_QSTR(MP_QSTR_TypeError), (mp_obj_t)&mp_type_TypeError }, { MP_OBJ_NEW_QSTR(MP_QSTR_ValueError), (mp_obj_t)&mp_type_ValueError }, diff --git a/py/obj.h b/py/obj.h index 68e048c2b6..3fa8a4d52a 100644 --- a/py/obj.h +++ b/py/obj.h @@ -339,7 +339,6 @@ extern const mp_obj_type_t mp_type_OverflowError; extern const mp_obj_type_t mp_type_RuntimeError; extern const mp_obj_type_t mp_type_StopIteration; extern const mp_obj_type_t mp_type_SyntaxError; -extern const mp_obj_type_t mp_type_SystemError; extern const mp_obj_type_t mp_type_SystemExit; extern const mp_obj_type_t mp_type_TypeError; extern const mp_obj_type_t mp_type_ValueError; diff --git a/py/objexcept.c b/py/objexcept.c index a9c0436e28..203517b106 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -268,7 +268,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) MP_DEFINE_EXCEPTION_BASE(IndentationError) MP_DEFINE_EXCEPTION(TabError, IndentationError) */ - MP_DEFINE_EXCEPTION(SystemError, Exception) + //MP_DEFINE_EXCEPTION(SystemError, Exception) MP_DEFINE_EXCEPTION(TypeError, Exception) MP_DEFINE_EXCEPTION(ValueError, Exception) //TODO: Implement UnicodeErrors which take arguments diff --git a/py/qstrdefs.h b/py/qstrdefs.h index c10b2fabac..0f520719f1 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -117,7 +117,6 @@ Q(OSError) Q(OverflowError) Q(RuntimeError) Q(SyntaxError) -Q(SystemError) Q(SystemExit) Q(TypeError) Q(UnboundLocalError) diff --git a/tests/basics/exceptpoly.py b/tests/basics/exceptpoly.py index 2dc68c13b5..b588c6b3bb 100644 --- a/tests/basics/exceptpoly.py +++ b/tests/basics/exceptpoly.py @@ -298,15 +298,15 @@ except SyntaxError: #except SyntaxWarning: # print("Caught SyntaxWarning") -try: - raise SystemError -except Exception: - print("Caught SystemError via Exception") +#try: +# raise SystemError +#except Exception: +# print("Caught SystemError via Exception") -try: - raise SystemError -except SystemError: - print("Caught SystemError") +#try: +# raise SystemError +#except SystemError: +# print("Caught SystemError") #try: # raise TabError diff --git a/tests/micropython/viper_misc.py b/tests/micropython/viper_misc.py index 7e6ed67d44..25dd473553 100644 --- a/tests/micropython/viper_misc.py +++ b/tests/micropython/viper_misc.py @@ -69,10 +69,10 @@ print(sorted(list(viper_set(1, 2)))) # raising an exception @micropython.viper def viper_raise(x:int): - raise SystemError(x) + raise OSError(x) try: viper_raise(1) -except SystemError as e: +except OSError as e: print(repr(e)) # this doesn't work at the moment diff --git a/tests/micropython/viper_misc.py.exp b/tests/micropython/viper_misc.py.exp index 2ea26ce990..a65bd2c52c 100644 --- a/tests/micropython/viper_misc.py.exp +++ b/tests/micropython/viper_misc.py.exp @@ -8,6 +8,6 @@ (1, 3) [1, 3] [1, 3] -SystemError(1,) +OSError(1,) 1 1