#NEWLINE# def readchar( fd ) : #NEWLINE# #INDENT# '\n    Read a character from the PTY at `fd`, or nothing if no data to read.\n    ' #NEWLINE# while True : #NEWLINE# #INDENT# ready = wait ( fd ) #NEWLINE# if ( len ( ready ) == 0 ) : #NEWLINE# #INDENT# return six . binary_type ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for s in ready : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return os . read ( s , 1 ) #NEWLINE# #UNINDENT# except OSError as ex : #NEWLINE# #INDENT# if ( ex . errno == errno . EIO ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# raise