Martin Panter added the comment: You might be right about the “reconstruction algorithm”. This text was added in revision 0bba533c0959; maybe Antoine can comment whether we should clarify or remove it.
I think the text added for TextIOBase.seek() in revision 03e61104f7a2 (Issue 12922) is closer to the truth. Though I would probably drop the bit about tell() not usually returning a byte position; for many codecs it does seem to. This illustrates the only four cases of seeking I understand are allowed for text streams: >>> text = TextIOWrapper(BytesIO(), "utf-7") >>> text.write("привет") 6 >>> text.seek(0) # 1: Rewind to start 0 >>> text.read(1) 'п' >>> saved = text.tell() >>> text.read() 'ривет' >>> text.seek(saved) # 2: Seek to saved offset 340282368347045388720132684115559317504 >>> text.read(1) 'р' >>> text.seek(0, SEEK_CUR) # 3: No movement 680564735267983852183507291547327528960 >>> text.read(1) 'и' >>> text.seek(0, SEEK_END) # 4: Seek to end 18 >>> text.read() # EOF '' If the “slow reconstruction algorithm” was clarified or removed, and the documentation explained that you cannot seek to arbitrary characters without having previously called tell(), would that work? ---------- nosy: +martin.panter, pitrou _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25849> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com