Message238699
You are probably right that the io classes are broken.
From https://docs.python.org/3/library/stdtypes.html#iterator-types:
Once an iterator’s __next__() method raises StopIteration, it must continue to do so on subsequent calls. Implementations that do not obey this property are deemed broken.
One consequence of __iter__ returning self is that the above is not guaranteed:
>>> with open('somefile', 'w') as f:
f.write('some text')
9
>>> with open('somefile', 'r') as f:
i = iter(f)
assert f is i
for line in i:
print(line)
try:
next(i)
except StopIteration:
print('exhausted iterator')
f.seek(0)
print(next(i))
some text
exhausted iterator
0
some text
So the io classes are *officially* broken. |
|
Date |
User |
Action |
Args |
2015-03-20 16:13:39 | wolma | set | recipients:
+ wolma, georg.brandl, paul.moore, ncoghlan, vstinner, r.david.murray, ethan.furman, python-dev, serhiy.storchaka, bkabrda, sYnfo |
2015-03-20 16:13:38 | wolma | set | messageid: <1426868018.97.0.21995057526.issue23700@psf.upfronthosting.co.za> |
2015-03-20 16:13:38 | wolma | link | issue23700 messages |
2015-03-20 16:13:38 | wolma | create | |
|