diff options
author | Raymond Hettinger <python@rcn.com> | 2004-12-20 23:55:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-12-20 23:55:32 (GMT) |
commit | 6266652cd73598af0b8cf069b14139be0b161102 (patch) | |
tree | 98576ace13e437ef78a955ff7e81d7cf059fd175 | |
parent | 21905e3e28c0b0c0e299adfc6048a7aee3cb8e33 (diff) | |
download | cpython-6266652cd73598af0b8cf069b14139be0b161102.zip cpython-6266652cd73598af0b8cf069b14139be0b161102.tar.gz cpython-6266652cd73598af0b8cf069b14139be0b161102.tar.bz2 |
SF bug #951915: fix bug in StringIO.truncate - length not changed
(Patch by Armin Rigo.)
-rw-r--r-- | Lib/StringIO.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 1dfc8b4..5c463fb 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -204,6 +204,7 @@ class StringIO: 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 @@ def test(): 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__': @@ -19,6 +19,9 @@ Core and builtins Library ------- +- StringIO.truncate() now correctly adjusts the size attribute. + (Bug #951915). + - The decimal module wouldn't run on builds without threads (Bug #1083645). - Bug #1086555: Fix leak in syslog module. |