summaryrefslogtreecommitdiff
path: root/extmod/uos_dupterm.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-06-13 12:37:49 +1000
committerDamien George <damien.p.george@gmail.com>2018-06-18 12:35:56 +1000
commite8398a58567cc94b866d46721fd06289601f5c8a (patch)
tree945e71ba803c72eb420b3b4d08c65cc647076027 /extmod/uos_dupterm.c
parent6abede2ca9e221b6aefcaccbda0c89e367507df1 (diff)
extmod: Update to use new mp_get_stream helper.
With this patch objects are only checked that they have the stream protocol at the start of their use as a stream, and afterwards the efficient mp_get_stream() helper is used to extract the stream protocol C methods.
Diffstat (limited to 'extmod/uos_dupterm.c')
-rw-r--r--extmod/uos_dupterm.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/extmod/uos_dupterm.c b/extmod/uos_dupterm.c
index 822d64037..cc6d97f41 100644
--- a/extmod/uos_dupterm.c
+++ b/extmod/uos_dupterm.c
@@ -62,7 +62,7 @@ int mp_uos_dupterm_rx_chr(void) {
if (nlr_push(&nlr) == 0) {
byte buf[1];
int errcode;
- const mp_stream_p_t *stream_p = mp_get_stream_raise(MP_STATE_VM(dupterm_objs[idx]), MP_STREAM_OP_READ);
+ const mp_stream_p_t *stream_p = mp_get_stream(MP_STATE_VM(dupterm_objs[idx]));
mp_uint_t out_sz = stream_p->read(MP_STATE_VM(dupterm_objs[idx]), buf, 1, &errcode);
if (out_sz == 0) {
nlr_pop();
@@ -125,6 +125,7 @@ STATIC mp_obj_t mp_uos_dupterm(size_t n_args, const mp_obj_t *args) {
if (args[0] == mp_const_none) {
MP_STATE_VM(dupterm_objs[idx]) = MP_OBJ_NULL;
} else {
+ mp_get_stream_raise(args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL);
MP_STATE_VM(dupterm_objs[idx]) = args[0];
}