#NEWLINE# def encode( value ) : #NEWLINE# #INDENT# if ( not isinstance ( value , compat . text_type ) ) : #NEWLINE# #INDENT# return value #NEWLINE# #UNINDENT# for char in ( '\\' , '\n' , '\t' ) : #NEWLINE# #INDENT# value = value . replace ( char , char . encode ( 'unicode-escape' ) ) #NEWLINE# #UNINDENT# return value . encode ( 'utf-8' )