diff --git a/py/builtintables.c b/py/builtintables.c index 7b35207fa5..5712a3ef56 100644 --- a/py/builtintables.c +++ b/py/builtintables.c @@ -123,7 +123,6 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_EOFError), (mp_obj_t)&mp_type_EOFError }, { MP_OBJ_NEW_QSTR(MP_QSTR_Exception), (mp_obj_t)&mp_type_Exception }, { MP_OBJ_NEW_QSTR(MP_QSTR_GeneratorExit), (mp_obj_t)&mp_type_GeneratorExit }, - { MP_OBJ_NEW_QSTR(MP_QSTR_IOError), (mp_obj_t)&mp_type_IOError }, { MP_OBJ_NEW_QSTR(MP_QSTR_ImportError), (mp_obj_t)&mp_type_ImportError }, { MP_OBJ_NEW_QSTR(MP_QSTR_IndentationError), (mp_obj_t)&mp_type_IndentationError }, { MP_OBJ_NEW_QSTR(MP_QSTR_IndexError), (mp_obj_t)&mp_type_IndexError }, diff --git a/py/obj.h b/py/obj.h index d96e4ec751..0156286818 100644 --- a/py/obj.h +++ b/py/obj.h @@ -326,7 +326,6 @@ extern const mp_obj_type_t mp_type_AttributeError; extern const mp_obj_type_t mp_type_EOFError; extern const mp_obj_type_t mp_type_Exception; extern const mp_obj_type_t mp_type_GeneratorExit; -extern const mp_obj_type_t mp_type_IOError; extern const mp_obj_type_t mp_type_ImportError; extern const mp_obj_type_t mp_type_IndentationError; extern const mp_obj_type_t mp_type_IndexError; diff --git a/py/objexcept.c b/py/objexcept.c index 7f0736543a..9b22acd995 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -224,10 +224,10 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) MP_DEFINE_EXCEPTION(AssertionError, Exception) MP_DEFINE_EXCEPTION(AttributeError, Exception) //MP_DEFINE_EXCEPTION(BufferError, Exception) - //MP_DEFINE_EXCEPTION(EnvironmentError, Exception) + //MP_DEFINE_EXCEPTION(EnvironmentError, Exception) use OSError instead MP_DEFINE_EXCEPTION(EOFError, Exception) MP_DEFINE_EXCEPTION(ImportError, Exception) - MP_DEFINE_EXCEPTION(IOError, Exception) + //MP_DEFINE_EXCEPTION(IOError, Exception) use OSError instead MP_DEFINE_EXCEPTION(LookupError, Exception) MP_DEFINE_EXCEPTION_BASE(LookupError) MP_DEFINE_EXCEPTION(IndexError, LookupError) diff --git a/py/qstrdefs.h b/py/qstrdefs.h index fda140f11f..6a63f0780b 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -105,7 +105,6 @@ Q(FileExistsError) Q(FileNotFoundError) Q(FloatingPointError) Q(GeneratorExit) -Q(IOError) Q(ImportError) Q(IndentationError) Q(IndexError) diff --git a/stmhal/modselect.c b/stmhal/modselect.c index a84c94554c..ff9df8f5ec 100644 --- a/stmhal/modselect.c +++ b/stmhal/modselect.c @@ -26,6 +26,7 @@ #include #include +#include #include "stm32f4xx_hal.h" @@ -213,7 +214,7 @@ STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t eventmas mp_obj_poll_t *self = self_in; mp_map_elem_t *elem = mp_map_lookup(&self->poll_map, mp_obj_id(obj_in), MP_MAP_LOOKUP); if (elem == NULL) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IOError, "object was never registered")); + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENOENT))); } ((poll_obj_t*)elem->value)->flags = mp_obj_get_int(eventmask_in); return mp_const_none; diff --git a/tests/basics/exceptpoly.py b/tests/basics/exceptpoly.py index 599a72b2a2..2dc68c13b5 100644 --- a/tests/basics/exceptpoly.py +++ b/tests/basics/exceptpoly.py @@ -108,15 +108,15 @@ except Exception: #except FutureWarning: # print("Caught FutureWarning") -try: - raise IOError -except Exception: - print("Caught IOError via Exception") +#try: +# raise IOError +#except Exception: +# print("Caught IOError via Exception") -try: - raise IOError -except IOError: - print("Caught IOError") +#try: +# raise IOError +#except IOError: +# print("Caught IOError") try: raise ImportError