Commit 92356dd0 authored by Guido van Rossum's avatar Guido van Rossum

[ 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.
parent f8ba6ff0
...@@ -129,6 +129,8 @@ class StringIO: ...@@ -129,6 +129,8 @@ class StringIO:
self.buflist = [] self.buflist = []
self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]] self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]]
self.buf = '' self.buf = ''
if newpos > self.len:
self.len = newpos
else: else:
self.buflist.append(s) self.buflist.append(s)
self.len = newpos self.len = newpos
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment