summaryrefslogtreecommitdiff
path: root/Lib/StringIO.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-12-20 23:51:53 +0000
committerRaymond Hettinger <python@rcn.com>2004-12-20 23:51:53 +0000
commit558fa92c3b6585e4fc87cf23d1aaab3072ba7ca4 (patch)
tree551cccdd8cc9e420cf43c92865f9101f50f84b2e /Lib/StringIO.py
parentf2c28f6ca1583ba77b5276435fac38c401bf368e (diff)
downloadcpython-558fa92c3b6585e4fc87cf23d1aaab3072ba7ca4.tar.gz
SF bug #951915: fix bug in StringIO.truncate - length not changed
(Patch by Armin Rigo.)
Diffstat (limited to 'Lib/StringIO.py')
-rw-r--r--Lib/StringIO.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
index 1dfc8b4d07..5c463fbc1c 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__':