def native_decode_source(text):
    """Use codec specified in file to decode to unicode
    Then, encode unicode to native str:
        Python 2: bytes
        Python 3: unicode
    """
    if ((only_python3 and isinstance(text, bytes))
            or (only_python2 and isinstance(text, str))):
        text = decode_source_to_unicode(text)
    if only_python2:
        return text.encode('ascii', 'replace')
    return text
Use codec specified in file to decode to unicode
    Then, encode unicode to native str:
        Python 2: bytes
        Python 3: unicode