Author serhiy.storchaka
Recipients James Hennessy, martin.panter, r.david.murray, serhiy.storchaka
Date 2016-04-19.05:05:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461042344.71.0.577714890919.issue26730@psf.upfronthosting.co.za>
In-reply-to
Content
> This still depends on StringIO.tell() corresponding to the number of code points, which is undocumented (we already disable newline translation in the StringIO). See also Issue 25190.

And doesn't work with Python implementation of StringIO. More general solution needs the code like:

pos = file.tell()
tail = file.read()
file.seek(0)
head = file.read()
if tail:
    head = head[:-len(tail)]
newfile.write(head)
pos = newfile.tell()  # TextIOWrapper position is opaque
newfile.write(tail)
newfile.seek(pos, 0)

Yet one bad thing with using independent StringIO instead of TextIOWrapper, is that saved tell() position becomes not valid after rollover(). I'm going to write few tests for cases when file position points not at the end of the stream.
History
Date User Action Args
2016-04-19 05:05:44serhiy.storchakasetrecipients: + serhiy.storchaka, r.david.murray, martin.panter, James Hennessy
2016-04-19 05:05:44serhiy.storchakasetmessageid: <1461042344.71.0.577714890919.issue26730@psf.upfronthosting.co.za>
2016-04-19 05:05:44serhiy.storchakalinkissue26730 messages
2016-04-19 05:05:44serhiy.storchakacreate