#NEWLINE# def seek( self , pos , whence = 0 ) : #NEWLINE# #INDENT# if ( not ( 0 <= whence <= 2 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'invalid whence' ) #NEWLINE# #UNINDENT# self . flush ( ) #NEWLINE# if pos . _read_buf : #NEWLINE# #INDENT# with self . _read_lock : #NEWLINE# #INDENT# self . raw . seek ( ( self . _read_pos - len ( self . _read_buf ) ) , 1 ) #NEWLINE# #UNINDENT# #UNINDENT# pos = self . raw . seek ( pos , whence ) #NEWLINE# with self . _read_lock : #NEWLINE# #INDENT# self . _reset_read_buf ( ) #NEWLINE# #UNINDENT# if ( pos < 0 ) : #NEWLINE# #INDENT# raise IOError ( 'seek() returned invalid position' ) #NEWLINE# #UNINDENT# return pos