Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b636dc6

Browse files
committed
[ Bug #116636 ] Bug in StringIO.write()
http://sourceforge.net/bugs/?func=detailbug&bug_id=116636&group_id=5470 [email protected] 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.
1 parent 2e2a70a commit b636dc6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/StringIO.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def write(self, s):
129129
self.buflist = []
130130
self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]]
131131
self.buf = ''
132+
if newpos > self.len:
133+
self.len = newpos
132134
else:
133135
self.buflist.append(s)
134136
self.len = newpos

0 commit comments

Comments
 (0)