Skip to content

Commit 8b03d94

Browse files
committed
py: Remove IOError since it's deprecated; use OSError instead.
In CPython IOError (and EnvironmentError) is deprecated and aliased to OSError. All modules that used to raise IOError now raise OSError (or a derived exception). In Micro Python we never used IOError (except 1 place, incorrectly) and so don't need to keep it. See http://legacy.python.org/dev/peps/pep-3151/ for background.
1 parent 1c6a1dc commit 8b03d94

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

py/builtintables.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
123123
{ MP_OBJ_NEW_QSTR(MP_QSTR_EOFError), (mp_obj_t)&mp_type_EOFError },
124124
{ MP_OBJ_NEW_QSTR(MP_QSTR_Exception), (mp_obj_t)&mp_type_Exception },
125125
{ MP_OBJ_NEW_QSTR(MP_QSTR_GeneratorExit), (mp_obj_t)&mp_type_GeneratorExit },
126-
{ MP_OBJ_NEW_QSTR(MP_QSTR_IOError), (mp_obj_t)&mp_type_IOError },
127126
{ MP_OBJ_NEW_QSTR(MP_QSTR_ImportError), (mp_obj_t)&mp_type_ImportError },
128127
{ MP_OBJ_NEW_QSTR(MP_QSTR_IndentationError), (mp_obj_t)&mp_type_IndentationError },
129128
{ MP_OBJ_NEW_QSTR(MP_QSTR_IndexError), (mp_obj_t)&mp_type_IndexError },

py/obj.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ extern const mp_obj_type_t mp_type_AttributeError;
326326
extern const mp_obj_type_t mp_type_EOFError;
327327
extern const mp_obj_type_t mp_type_Exception;
328328
extern const mp_obj_type_t mp_type_GeneratorExit;
329-
extern const mp_obj_type_t mp_type_IOError;
330329
extern const mp_obj_type_t mp_type_ImportError;
331330
extern const mp_obj_type_t mp_type_IndentationError;
332331
extern const mp_obj_type_t mp_type_IndexError;

py/objexcept.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
224224
MP_DEFINE_EXCEPTION(AssertionError, Exception)
225225
MP_DEFINE_EXCEPTION(AttributeError, Exception)
226226
//MP_DEFINE_EXCEPTION(BufferError, Exception)
227-
//MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
227+
//MP_DEFINE_EXCEPTION(EnvironmentError, Exception) use OSError instead
228228
MP_DEFINE_EXCEPTION(EOFError, Exception)
229229
MP_DEFINE_EXCEPTION(ImportError, Exception)
230-
MP_DEFINE_EXCEPTION(IOError, Exception)
230+
//MP_DEFINE_EXCEPTION(IOError, Exception) use OSError instead
231231
MP_DEFINE_EXCEPTION(LookupError, Exception)
232232
MP_DEFINE_EXCEPTION_BASE(LookupError)
233233
MP_DEFINE_EXCEPTION(IndexError, LookupError)

py/qstrdefs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Q(FileExistsError)
105105
Q(FileNotFoundError)
106106
Q(FloatingPointError)
107107
Q(GeneratorExit)
108-
Q(IOError)
109108
Q(ImportError)
110109
Q(IndentationError)
111110
Q(IndexError)

stmhal/modselect.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <stdint.h>
2828
#include <stdio.h>
29+
#include <errno.h>
2930

3031
#include "stm32f4xx_hal.h"
3132

@@ -213,7 +214,7 @@ STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t eventmas
213214
mp_obj_poll_t *self = self_in;
214215
mp_map_elem_t *elem = mp_map_lookup(&self->poll_map, mp_obj_id(obj_in), MP_MAP_LOOKUP);
215216
if (elem == NULL) {
216-
nlr_raise(mp_obj_new_exception_msg(&mp_type_IOError, "object was never registered"));
217+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENOENT)));
217218
}
218219
((poll_obj_t*)elem->value)->flags = mp_obj_get_int(eventmask_in);
219220
return mp_const_none;

tests/basics/exceptpoly.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@
108108
#except FutureWarning:
109109
# print("Caught FutureWarning")
110110

111-
try:
112-
raise IOError
113-
except Exception:
114-
print("Caught IOError via Exception")
111+
#try:
112+
# raise IOError
113+
#except Exception:
114+
# print("Caught IOError via Exception")
115115

116-
try:
117-
raise IOError
118-
except IOError:
119-
print("Caught IOError")
116+
#try:
117+
# raise IOError
118+
#except IOError:
119+
# print("Caught IOError")
120120

121121
try:
122122
raise ImportError

0 commit comments

Comments
 (0)