8000 stream: Return errno value as first arg of OSError exception. · rpavlik/circuitpython@0c7b26c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c7b26c

Browse files
committed
stream: Return errno value as first arg of OSError exception.
This is CPython-compatible convention established yet in acb1388.
1 parent 067ae12 commit 0c7b26c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

py/stream.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
110110
}
111111
break;
112112
}
113-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error));
113+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error)));
114114
}
115115

116116
if (out_sz < more_bytes) {
@@ -178,7 +178,7 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
178178
// this as EOF.
179179
return mp_const_none;
180180
}
181-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error));
181+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error)));
182182
} else {
183183
mp_obj_t s = mp_obj_new_str_of_type(STREAM_CONTENT_TYPE(o->type->stream_p), buf, out_sz); // will reallocate to use exact size
184184
m_free(buf, sz);
@@ -204,7 +204,7 @@ mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len) {
204204
// see abobe.
205205
return mp_const_none;
206206
}
207-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error));
207+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error)));
208208
} else {
209209
return MP_OBJ_NEW_SMALL_INT(out_sz);
210210
}
@@ -240,7 +240,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
240240
}
241241
break;
242242
}
243-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error));
243+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error)));
244244
}
245245
if (out_sz == 0) {
246246
break;
@@ -293,7 +293,7 @@ STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) {
293293

294294
mp_uint_t out_sz = o->type->stream_p->read(o, p, 1, &error);
295295
if (out_sz == MP_STREAM_ERROR) {
296-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error));
296+
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error)));
297297
}
298298
if (out_sz == 0) {
299299
// Back out previously added byte

0 commit comments

Comments
 (0)
0