def to_unicode(text, encoding=None, errors='strict'):
    """Return the unicode representation of a bytes object ``text``. If
    ``text`` is already an unicode object, return it as-is."""
    if isinstance(text, str):
        return text
    if not isinstance(text, (bytes, str)):
        raise TypeError(
            'to_unicode must receive a bytes or str object, got %s' % type(
            text).__name__)
    if encoding is None:
        encoding = 'utf-8'
    return text.decode(encoding, errors)
