diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-10-16 02:56:24 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-10-16 02:58:52 +0300 |
commit | 0c7b26c0f816664222c8495d7cb5c44d40acd009 (patch) | |
tree | f97b45a0575b5ad04f21c2baf66aeac53f6c14c7 /py/stream.c | |
parent | 067ae1269d53b57506cfb86d0d450b4e12fa260a (diff) | |
download | micropython-0c7b26c0f816664222c8495d7cb5c44d40acd009.tar.gz micropython-0c7b26c0f816664222c8495d7cb5c44d40acd009.zip |
stream: Return errno value as first arg of OSError exception.
This is CPython-compatible convention established yet in acb13886fc837a1bb9.
Diffstat (limited to 'py/stream.c')
-rw-r--r-- | py/stream.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/py/stream.c b/py/stream.c index c1430e3580..862f3e6259 100644 --- a/py/stream.c +++ b/py/stream.c @@ -110,7 +110,7 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) { } break; } - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error))); } if (out_sz < more_bytes) { @@ -178,7 +178,7 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) { // this as EOF. return mp_const_none; } - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error))); } else { 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 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) { // see abobe. return mp_const_none; } - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error))); } else { return MP_OBJ_NEW_SMALL_INT(out_sz); } @@ -240,7 +240,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) { } break; } - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error))); } if (out_sz == 0) { break; @@ -293,7 +293,7 @@ STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) { mp_uint_t out_sz = o->type->stream_p->read(o, p, 1, &error); if (out_sz == MP_STREAM_ERROR) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); + nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(error))); } if (out_sz == 0) { // Back out previously added byte |