unix io.FileIO: Add iteration support.
A file cannot be iterated concurrently, so we make io.FileIO its own iterator.
This commit is contained in:
parent
d54bef7692
commit
decd597273
3
tests/io/file-iter.py
Normal file
3
tests/io/file-iter.py
Normal file
@ -0,0 +1,3 @@
|
||||
f = open("io/data/file1")
|
||||
for l in f:
|
||||
print(l)
|
@ -102,8 +102,8 @@ static const mp_obj_type_t rawfile_type = {
|
||||
"io.FileIO",
|
||||
.print = fdfile_print,
|
||||
.make_new = fdfile_make_new,
|
||||
.getiter = NULL,
|
||||
.iternext = NULL,
|
||||
.getiter = mp_identity,
|
||||
.iternext = mp_stream_unbuffered_iter,
|
||||
.stream_p = {
|
||||
.read = fdfile_read,
|
||||
.write = fdfile_write,
|
||||
|
Loading…
x
Reference in New Issue
Block a user