<s> import sys <EOL> try : <EOL> pyreadline_codepage = sys . stdout . encoding <EOL> except AttributeError : <EOL> pyreadline_codepage = "<STR_LIT:ascii>" <EOL> def ensure_unicode ( text ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( text , str ) : <EOL> return text . decode ( pyreadline_codepage , "<STR_LIT:replace>" ) <EOL> return text <EOL> def ensure_str ( text ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( text , unicode ) : <EOL> return text . encode ( pyreadline_codepage , "<STR_LIT:replace>" ) <EOL> return text </s>
