def bytes2str(bstr):
    """Convert a bytes into string."""
    if type(bstr) is bytes:
        return bstr.decode('utf-8')
    elif type(bstr) is str:
        return bstr
    else:
        raise TypeError(
            bstr, ' should be a bytes or str but got ', type(bstr), ' instead')