diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-15 23:23:36 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-27 00:04:20 +0300 |
commit | f5f6c3b7920457e99b71cf58cfb3cb0be0e4e890 (patch) | |
tree | 79cf4f53f07573e4961945ec6f356d3c560d2c50 /py | |
parent | ce81312d8a81c7579ecc35ccdc53a49543c0b0d5 (diff) | |
download | micropython-f5f6c3b7920457e99b71cf58cfb3cb0be0e4e890.tar.gz micropython-f5f6c3b7920457e99b71cf58cfb3cb0be0e4e890.zip |
streams: Reading by char count from unicode text streams is not implemented.
Diffstat (limited to 'py')
-rw-r--r-- | py/stream.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/py/stream.c b/py/stream.c index 07a79248ab..a5a96a8682 100644 --- a/py/stream.c +++ b/py/stream.c @@ -33,6 +33,7 @@ #include "qstr.h" #include "obj.h" #include "objstr.h" +#include "runtime.h" #include "stream.h" #if MICROPY_STREAMS_NON_BLOCK #include <errno.h> @@ -67,6 +68,13 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) { if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) { return stream_readall(args[0]); } + + #if MICROPY_PY_BUILTINS_STR_UNICODE + if (!o->type->stream_p->is_bytes) { + mp_not_implemented("Reading from unicode text streams by character count"); + } + #endif + byte *buf = m_new(byte, sz); int error; machine_int_t out_sz = o->type->stream_p->read(o, buf, sz, &error); |