def autodecode(b):
    """ Try to decode ``bytes`` to text - try default encoding first, otherwise try to autodetect

    Args:
        b (bytes): byte string

    Returns:
        str: decoded text string
    """
    import warnings
    import chardet

    try:
        return b.decode()
    except UnicodeError:
        result = chardet.detect(b)
        if result['confidence'] < 0.95:
            warnings.warn('autodecode failed with utf-8; guessing %s' % result['encoding'])
        return result.decode(result['encoding'])