@staticmethod<EOL><INDENT>def write_in_tmpfile(text, tmpfile):<DEDENT>
try:<EOL><INDENT>tmpfile.write(text)<EOL><DEDENT>except TypeError:<EOL><INDENT>tmpfile.write(str.encode(text))<EOL><DEDENT>except UnicodeEncodeError:<EOL><INDENT>tmpfile.write(text.encode("<STR_LIT:utf-8>"))<EOL><DEDENT>
Write the given text in the given tmpfile in python2 and python3.