def safe_decode(string, current_encoding='utf-8', errors='strict'):
    """Decode a byte string.

    Raises a SafeDecodeError if current_encoding cannot decode the string and
    the value of errors causes an exception to be raised.
    If given a unicde type, returns it immediately.
    Given any other type, returns unicode() version of it.

    Args:
      string: str String to decode.
      target_encoding: str Encoding to decode with. Default 'utf-8'.
      errors: str Name of the error handler to call if something goes wrong.
              See docs on the codecs module. Default 'strict'.

    Returns:
      A unicode string, or raises an error.

    """
    if isinstance(string, str):
        try:
            return string.decode(current_encoding, errors)
        except __HOLE__:
            raise SafeDecodeError(current_encoding + ' could not decode ' +
                                  repr(string))
    elif isinstance(string, unicode):
        return string
    else:
        # Got something elese, probably an int or bool or the like.
        return unicode(string)
dataset/ETHPy150Open vinitkumar/googlecl/src/googlecl/__init__.py/safe_decode