def _isascii(string):
    """Tests if a given string is pure ASCII; works for both Python 2 and 3"""
    try:
        return len(string) == len(string.encode())
    except UnicodeDecodeError:
        return False
    except UnicodeEncodeError:
        return False