Mercurial > cpython-lru_cache-weakref
diff Lib/StringIO.py @ 34207:19286994f74f 2.4
SF bug #951915: fix bug in StringIO.truncate - length not changed
(Patch by Armin Rigo.)
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Mon, 20 Dec 2004 23:55:32 +0000 |
| parents | 6d055a275b4b |
| children | 8e8d0e03f076 |
line wrap: on
line diff
--- a/Lib/StringIO.py Mon Dec 20 12:26:43 2004 +0000 +++ b/Lib/StringIO.py Mon Dec 20 23:55:32 2004 +0000 @@ -204,6 +204,7 @@ elif size < self.pos: self.pos = size self.buf = self.getvalue()[:size] + self.len = size def write(self, s): """Write a string to the file. @@ -312,6 +313,11 @@ print 'File length =', f.tell() if f.tell() != length: raise RuntimeError, 'bad length' + f.truncate(length/2) + f.seek(0, 2) + print 'Truncated length =', f.tell() + if f.tell() != length/2: + raise RuntimeError, 'truncate did not adjust length' f.close() if __name__ == '__main__':
