2007-05-04

BaseException.message is now deprecated

Back when I wrote PEP 352 with Guido we had decided that trying to clean up the interface of exceptions was a good thing along with anchoring the exception hierarchy at a set point. And so, along with introducing the 'message' attribute we decided exceptions should only take a single argument.

Well, that didn't turn out well. The restriction of BaseException's constructor to a single parameter turned out to be extremely painful. And so the decision was made to scrap that part of PEP 352.

But what about 'message'? It was added to help transition to BaseException taking only a single parameter and get people off of 'args'. But it had weird semantics; if you had more than one argument to the constructor it was not set. And with BaseException already having 'args' and continuing to all multiple arguments, its usefulness was questioned.

And so, the question was asked whether we should keep it on this blog. I also asked on python-dev. The general reaction was that 'message' was not really needed and essentially a mistake. I realize now what should have been done was a PendingDeprecationWarning on BaseException for multiple arguments for a while, then make it a DeprecationWarning. But I didn't think of that when PEP 352 was written.

And so, now BaseException.message is deprecated in Python 2.6. It will go away in Python 3.0 and have lived life as probably the most short-lived feature in Python's history. =)

And so another thing comes off the TODO list. The list is finally starting to get into Py3K stuff which is good since I need to get that done by some time in June.