[Python-Dev] Python 2.6 BaseException.message deprecation, really needed?

Brett Cannon brett at python.org
Sun Jul 8 02:42:18 CEST 2007

On 7/7/07, Gustavo Carneiro <gjcarneiro at gmail.com> wrote:
> In PyGObject we want to use a 'message' attribute in an exception defined by
> us.  The name 'message' comes from a C API, therefore we would like to keep
> it for easier mapping between C and Python APIs.  Why does Python have to
> deprecate this attribute?

It's going away in Python 3.0.  In retrospect the attribute was a
mistake thanks to its odd semantics to be backwards compatible in a
reasonable way.  Plus its removal from the code base was nasty mostly
thanks to C-based exceptions.

> .../gobject/option.py:187: DeprecationWarning: BaseException.message has
> been deprecated as of Python 2.6
>   gerror.message = str(error)

You can get around this easily enough with a subclass that uses a
property for message::

  class gerror(Exception):
    def _get_message(self, message): return self._message
    def _set_message(self, message): self._message = message
    message = property(_get_message, _set_message)


More information about the Python-Dev mailing list