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.
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index 7e75879..b7333fd 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -289,6 +289,7 @@
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;