#NEWLINE# def handle_stdin( self , input_ , output , echo ) : #NEWLINE# #INDENT# '\n        Read local stdin, copying into process\' stdin as necessary.\n\n        Intended for use as a thread target.\n\n        .. note::\n            Because real terminal stdin streams have no well-defined "end", if\n            such a stream is detected (based on existence of a callable\n            ``.fileno()``) this method will wait until `program_finished` is\n            set, before terminating.\n\n            When the stream doesn\'t appear to be from a terminal, the same\n            semantics as `handle_stdout` are used - the stream is simply\n            ``read()`` from until it returns an empty value.\n\n        :param input_: Stream (file-like object) from which to read.\n        :param output: Stream (file-like object) to which echoing may occur.\n        :param bool echo: User override option for stdin-stdout echoing.\n\n        :returns: ``None``.\n        ' #NEWLINE# with character_buffered ( input_ ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# byte = None #NEWLINE# if ready_for_reading ( input_ ) : #NEWLINE# #INDENT# byte = read_byte ( input_ ) #NEWLINE# if ( not byte ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# self . write_stdin ( self . encode ( byte ) ) #NEWLINE# if ( echo is None ) : #NEWLINE# #INDENT# echo = self . echo_stdin ( input_ , self ) #NEWLINE# #UNINDENT# if echo : #NEWLINE# #INDENT# output . write ( byte ) #NEWLINE# output . flush ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( self . program_finished . is_set ( ) and ( not byte ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# time . sleep ( self . input_sleep )