def is_ascii_encodable(s):
    """Check if argument encodes to ascii without error."""
    try:
        s.encode('ascii')
    except UnicodeEncodeError:
        # NOTE(tbug): Py2 and Py3 will raise this if string contained
        # chars that could not be ascii encoded
        return False
    except UnicodeDecodeError:
        # NOTE(tbug): py2 will raise this if type is str
        # and contains non-ascii chars
        return False
    except __HOLE__:
        # NOTE(tbug): s is probably not a string type
        return False
    return True
dataset/ETHPy150Open falconry/falcon/falcon/response_helpers.py/is_ascii_encodable