def to_ascii(_str, on_error='ignore'):
    """convert unicode to ascii if necessary"""
    # python 3 renamed unicode to str
    args = get_args()
    if sys.version_info >= (3, 0):
        if isinstance(_str, bytes) and not args.ascii:
            return str(_str, "utf-8")
        elif isinstance(_str, str) and args.ascii:
            return _str.encode("ascii", on_error).decode("utf-8")
        else:
            return _str
    else:
        if isinstance(_str, str) and not args.ascii:
            return unicode(_str, "utf-8")
        elif isinstance(_str, unicode) and args.ascii:
            return _str.encode("ascii", on_error).decode("utf-8")
        else:
            return _str
convert unicode to ascii if necessary
spotify_ripper/utils.py