summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-12-20 23:51:53 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-12-20 23:51:53 (GMT)
commit6065d3232520b52f5196c31738dcbfb355ee9a4c (patch)
tree0edcc1c71bd514598c29e95f69304c0874f4d76f /Lib
parent2ccea1785603ad35a05f75f40e9dc7fc82caa346 (diff)
downloadcpython-6065d3232520b52f5196c31738dcbfb355ee9a4c.zip
cpython-6065d3232520b52f5196c31738dcbfb355ee9a4c.tar.gz
cpython-6065d3232520b52f5196c31738dcbfb355ee9a4c.tar.bz2
SF bug #951915: fix bug in StringIO.truncate - length not changed
(Patch by Armin Rigo.)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/StringIO.py6
1 files changed, 6 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__':