File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ def truncate(self, size=None):
204204 elif size < self .pos :
205205 self .pos = size
206206 self .buf = self .getvalue ()[:size ]
207+ self .len = size
207208
208209 def write (self , s ):
209210 """Write a string to the file.
@@ -312,6 +313,11 @@ def test():
312313 print 'File length =' , f .tell ()
313314 if f .tell () != length :
314315 raise RuntimeError , 'bad length'
316+ f .truncate (length / 2 )
317+ f .seek (0 , 2 )
318+ print 'Truncated length =' , f .tell ()
319+ if f .tell () != length / 2 :
320+ raise RuntimeError , 'truncate did not adjust length'
315321 f .close ()
316322
317323if __name__ == '__main__' :
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ Extension Modules
3030Library
3131-------
3232
33+ - StringIO.truncate() now correctly adjusts the size attribute.
34+ (Bug #951915).
35+
3336- locale.py now uses an updated locale alias table (built using
3437 Tools/i18n/makelocalealias.py, a tool to parse the X11 locale
3538 alias file); the encoding lookup was enhanced to use Python's
You can’t perform that action at this time.
0 commit comments