Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
0c7b26c0
Commit
0c7b26c0
authored
Oct 16, 2014
by
Paul Sokolovsky
Browse files
stream: Return errno value as first arg of OSError exception.
This is CPython-compatible convention established yet in
acb13886
.
parent
067ae126
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/stream.c
View file @
0c7b26c0
...
...
@@ -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_v
arg
(
&
mp_type_OSError
,
"[Errno %d]"
,
error
));
nlr_raise
(
mp_obj_new_exception_arg
1
(
&
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_v
arg
(
&
mp_type_OSError
,
"[Errno %d]"
,
error
));
nlr_raise
(
mp_obj_new_exception_arg
1
(
&
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_v
arg
(
&
mp_type_OSError
,
"[Errno %d]"
,
error
));
nlr_raise
(
mp_obj_new_exception_arg
1
(
&
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_v
arg
(
&
mp_type_OSError
,
"[Errno %d]"
,
error
));
nlr_raise
(
mp_obj_new_exception_arg
1
(
&
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_v
arg
(
&
mp_type_OSError
,
"[Errno %d]"
,
error
));
nlr_raise
(
mp_obj_new_exception_arg
1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
error
))
)
;
}
if
(
out_sz
==
0
)
{
// Back out previously added byte
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment