summaryrefslogtreecommitdiff
path: root/py/stream.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-06-28 10:30:53 +0100
committerDamien George <damien.p.george@gmail.com>2014-06-28 10:30:53 +0100
commitb1b840554d27659f760304713c98f5c7f2d7f74b (patch)
treec112d08faa88043084f4d4d19094127b31d4e2c2 /py/stream.c
parent8993fb6cf0677ce980ab56cbad326e4e6bc47811 (diff)
parent635b60e299509a85722db77c4409c78ca86dbdc7 (diff)
Merge branch 'unicode'
Diffstat (limited to 'py/stream.c')
-rw-r--r--py/stream.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/py/stream.c b/py/stream.c
index 07a79248a..a5a96a868 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);