@cached_property
    def message(self):
        """The formatted message."""
        if not (self.args or self.kwargs):
            return self.msg
        try:
            try:
                return self._format_message(self.msg, *self.args,
                                            **self.kwargs)
            except UnicodeDecodeError:
                # Assume an unicode message but mixed-up args
                msg = self.msg.encode('utf-8', 'replace')
                return self._format_message(msg, *self.args, **self.kwargs)
            except (UnicodeEncodeError, __HOLE__):
                # we catch AttributeError since if msg is bytes,
                # it won't have the 'format' method
                if (sys.exc_info()[0] is AttributeError
                        and (PY2 or not isinstance(self.msg, bytes))):
                    # this is not the case we thought it is...
                    raise
                # Assume encoded message with unicode args.
                # The assumption of utf8 as input encoding is just a guess,
                # but this codepath is unlikely (if the message is a constant
                # string in the caller's source file)
                msg = self.msg.decode('utf-8', 'replace')
                return self._format_message(msg, *self.args, **self.kwargs)

        except Exception:
            # this obviously will not give a proper error message if the
            # information was not pulled and the log record no longer has
            # access to the frame.  But there is not much we can do about
            # that.
            e = sys.exc_info()[1]
            errormsg = ('Could not format message with provided '
                        'arguments: {err}\n  msg={msg!r}\n  '
                        'args={args!r} \n  kwargs={kwargs!r}.\n'
                        'Happened in file {file}, line {lineno}').format(
                err=e, msg=self.msg, args=self.args,
                kwargs=self.kwargs, file=self.filename,
                lineno=self.lineno
            )
            if PY2:
                errormsg = errormsg.encode('utf-8')
            raise TypeError(errormsg)
dataset/ETHPy150Open getlogbook/logbook/logbook/base.py/LogRecord.message