def ensure_str(text):
    if isinstance(text, unicode):
        return text.encode(pyreadline_codepage, "replace")
    return text
Convert unicode to str using pyreadline_codepage
dataset/ETHPy150Open deanhiller/databus/webapp/play1.3.x/python/Lib/site-packages/pyreadline/unicode_helper.py/ensure_str