mirror of
https://github.com/python/cpython.git
synced 2025-10-26 19:24:34 +00:00
Patch 1012740: cStringIO's truncate doesn't
truncate() left the stream position unchanged, which meant the
"truncated" data didn't go away:
>>> io.write('abc')
>>> io.truncate(0)
>>> io.write('xyz')
>>> io.getvalue()
'abcxyz'
Patch by Dima Dorfman.
This commit is contained in:
parent
7109b287cf
commit
037b3ee44e
3 changed files with 9 additions and 2 deletions
|
|
@ -49,9 +49,10 @@ def test_truncate(self):
|
|||
f.seek(10)
|
||||
f.truncate()
|
||||
eq(f.getvalue(), 'abcdefghij')
|
||||
f.seek(0)
|
||||
f.truncate(5)
|
||||
eq(f.getvalue(), 'abcde')
|
||||
f.write('xyz')
|
||||
eq(f.getvalue(), 'abcdexyz')
|
||||
f.close()
|
||||
self.assertRaises(ValueError, f.write, 'frobnitz')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue