summaryrefslogtreecommitdiff
path: root/py/stream.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-02-15 16:53:19 -0800
committerScott Shawcroft <scott@tannewt.org>2019-02-15 16:53:19 -0800
commite6b140e7a0cf07fa365269e7801bb111565cb478 (patch)
tree154bc46fe82bed0035f50d683b74d8e35b8b5f2f /py/stream.c
parent35e3d99f62f908f6f371667b13120e20edb1142f (diff)
Support print("", flush=True)
Fixes #1127
Diffstat (limited to 'py/stream.c')
-rw-r--r--py/stream.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/py/stream.c b/py/stream.c
index 9d8be445c..08c749cc3 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -468,16 +468,19 @@ STATIC mp_obj_t stream_tell(mp_obj_t self) {
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_tell_obj, stream_tell);
-STATIC mp_obj_t stream_flush(mp_obj_t self) {
+mp_obj_t mp_stream_flush(mp_obj_t self) {
const mp_stream_p_t *stream_p = mp_get_stream(self);
int error;
+ if (stream_p->ioctl == NULL) {
+ mp_raise_OSError(MP_EINVAL);
+ }
mp_uint_t res = stream_p->ioctl(self, MP_STREAM_FLUSH, 0, &error);
if (res == MP_STREAM_ERROR) {
mp_raise_OSError(error);
}
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_flush_obj, stream_flush);
+MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_flush_obj, mp_stream_flush);
STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo;