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:
Tim Peters 2004-08-21 06:55:43 +00:00
parent 7109b287cf
commit 037b3ee44e
3 changed files with 9 additions and 2 deletions

View file

@ -289,6 +289,7 @@ IO_truncate(IOobject *self, PyObject *args) {
if (pos < 0) pos = self->pos;
if (self->string_size > pos) self->string_size = pos;
self->pos = self->string_size;
Py_INCREF(Py_None);
return Py_None;