Skip to content

Commit f5f6c3b

Browse files
committed
streams: Reading by char count from unicode text streams is not implemented.
1 parent ce81312 commit f5f6c3b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

py/stream.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "qstr.h"
3434
#include "obj.h"
3535
#include "objstr.h"
36+
#include "runtime.h"
3637
#include "stream.h"
3738
#if MICROPY_STREAMS_NON_BLOCK
3839
#include <errno.h>
@@ -67,6 +68,13 @@ STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
6768
if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) {
6869
return stream_readall(args[0]);
6970
}
71+
72+
#if MICROPY_PY_BUILTINS_STR_UNICODE
73+
if (!o->type->stream_p->is_bytes) {
74+
mp_not_implemented("Reading from unicode text streams by character count");
75+
}
76+
#endif
77+
7078
byte *buf = m_new(byte, sz);
7179
int error;
7280
machine_int_t out_sz = o->type->stream_p->read(o, buf, sz, &error);

0 commit comments

Comments
 (0)