def as_text(str_or_bytes, encoding='<STR_LIT:utf-8>', errors='<STR_LIT:strict>'):
if isinstance(str_or_bytes, text):<EOL><INDENT>return str_or_bytes<EOL><DEDENT>return str_or_bytes.decode(encoding, errors)<EOL>
Return input string as a text string.

    Should work for input string that's unicode or bytes,
    given proper encoding.

    >>> print(as_text(b'foo'))
    foo
    >>> b'foo'.decode('utf-8') == u'foo'
    True