[ Bug #116636 ] Bug in StringIO.write()

http://sourceforge.net/bugs/?func=detailbug&bug_id=116636&group_id=5470
bobalex@rsv.ricoh.com

Bug report: If the file position is less than the end of the "file",
and a write is performed extending past then end of the file, the data
string is corrupted.

Solution: in write(), when writing past the end, properly set self.len
when newpos is > self.len.
This commit is contained in:
Guido van Rossum 2000-10-12 16:45:37 +00:00
parent 2e2a70abe4
commit b636dc67ed
1 changed files with 2 additions and 0 deletions

View File

@ -129,6 +129,8 @@ class StringIO:
self.buflist = []
self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]]
self.buf = ''
if newpos > self.len:
self.len = newpos
else:
self.buflist.append(s)
self.len = newpos