#NEWLINE# def truncate( self , size = DEFAULT ) : #NEWLINE# #INDENT# '\n        truncate([size]) -> None.\n\n        Truncate the file to at most size bytes.\n\n        Size defaults to the current file position, as returned by tell().\n        ' #NEWLINE# if ( self . mode in READ_MODES ) : #NEWLINE# #INDENT# raise IOError ( 'Bad file descriptor' ) #NEWLINE# #UNINDENT# if ( size is not DEFAULT ) : #NEWLINE# #INDENT# size = self . _check_int_argument ( size ) #NEWLINE# if ( size < 0 ) : #NEWLINE# #INDENT# raise IOError ( 'Invalid argument' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# size = self . _position #NEWLINE# #UNINDENT# data = self . _data [ : size ] #NEWLINE# self . _data = ( data + ( ( size - len ( data ) ) * '\x00' ) ) #NEWLINE# self . flush ( )