Message263708
> 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. |
|
Date |
User |
Action |
Args |
2016-04-19 05:05:44 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, r.david.murray, martin.panter, James Hennessy |
2016-04-19 05:05:44 | serhiy.storchaka | set | messageid: <1461042344.71.0.577714890919.issue26730@psf.upfronthosting.co.za> |
2016-04-19 05:05:44 | serhiy.storchaka | link | issue26730 messages |
2016-04-19 05:05:44 | serhiy.storchaka | create | |
|