def safe_revision_id(unicode_or_utf8_string):
    """Revision ids should now be utf8, but at one point they were unicode.

    :param unicode_or_utf8_string: A possibly Unicode revision_id. (can also be
        utf8 or None).
    :return: None or a utf8 revision id.
    """
    if (unicode_or_utf8_string is None or unicode_or_utf8_string.__class__ ==
        bytes):
        return unicode_or_utf8_string
    raise TypeError(
        'Unicode revision ids are no longer supported. Revision id generators should be creating utf8 revision ids.'
        )
