using 'message' in a BzrError format string results in unprintable exceptions

Bug #110143 reported by Robert Collins
This bug report is a duplicate of:  Bug #144633: KeyError for BzrCheckError.message. Edit Remove
2
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
High
Unassigned

Bug Description

BzrError formats the _fmt using self.__dict__.

However, self.message does not appear in self.__dict__ because its
handled by a data descriptor in BaseException.

We might be able to fix this with some python innards voodoo, but for
now, just documenting that its bad and correcting our usage of 'message'
in the format strings is sufficient.

BzrCheckError, WeaveError, are broken.

e.g.
>>> str(errors.BzrCheckError('foo'))
"Unprintable exception BzrCheckError: dict={'_preformatted_string':
None}, fmt='Internal check failed: %(message)s',
error=KeyError('message',)"

 affects /products/bzr
 status confirmed
 importance high

-Rob

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 110143] using 'message' in a BzrError format string results in unprintable exceptions

Robert Collins пишет:
> Public bug reported:
>
> BzrError formats the _fmt using self.__dict__.
>
> However, self.message does not appear in self.__dict__ because its
> handled by a data descriptor in BaseException.
>
> We might be able to fix this with some python innards voodoo, but for
> now, just documenting that its bad and correcting our usage of 'message'
> in the format strings is sufficient.
>
> BzrCheckError, WeaveError, are broken.
>
> e.g.
>>>> str(errors.BzrCheckError('foo'))
> "Unprintable exception BzrCheckError: dict={'_preformatted_string':
> None}, fmt='Internal check failed: %(message)s',
> error=KeyError('message',)"
>
> affects /products/bzr
> status confirmed
> importance high

This issue exist in Python 2.5, because in 2.5 exceptions now new-style classes,
and 'messages' listed in __slots__. For LockError I recently changed 'message' to 'msg'.
I think we need to change and other places too.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.