[Python-Dev] deprecating BaseException.message (original) (raw)

Tres Seaver tseaver at palladion.com
Mon Apr 6 18:15:43 CEST 2009


-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Brett Cannon wrote:

During the PyCon sprint I tried to make BaseException accept only a single argument and bind it to BaseException.message . I was successful (see the p3yknoargsonexc branch), but it was very painful to pull off as anyone who sat around me the last three days of the sprint will tell you as they had to listen to me curse incessantly.

Because of the pain that I went through in the transition and thus the lessons learned, Guido and I discussed it and we think it would be best to give up on forcing BaseException to accept only a single argument. I think it is still doable, but requires a multi-release transition period and not the one that 2.6 -> 3.0 is offering. And so Guido and I plan on deprecating BaseException.message as its entire point in existence was to help transition to what we are not going to have happen. =) Now that means BaseException.message might hold the record for shortest lived feature as it was only introduced in 2.5 and is now to be deprecated in 2.6 and removed in 2.7/3.0. =) Below is PEP 352, revised to reflect the removal of BaseException.messageand for letting the 'args' attribute stay (along with suggesting one should only pass a single argument to BaseException). Basically the interface for exceptions doesn't really change in 3.0 except for the removal of getitem.

Hmm, I'm working on cleaning up deprecations for Zope and related packages under Python 2.6. The irony here is that I'm receiving deprecation warnings for custom exception classes which had a 'message' attribute long before the abortive attempt to add them to the BaseException type, which hardly seems reasonable.

For instance, docutils.parsers.rst defines a DirectiveError which takes two arguments, 'level' and 'message', and therefore gets hit with the deprecation (even though it never used the new signature). Likewise, ZODB.POSException defines a ConflictError type which takes 'message' as one of several arguments, all optional, and has since at least 2002.

I don't think either of these classes should be subject to a deprecation warning for a feature they never used or depended on.

Tres. - --

Tres Seaver +1 540-429-0999 tseaver at palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ2iqv+gerLs4ltQ4RArg7AJ9cjTweXUuGdUZNxZ3dHzYb9u6AcQCePJW/ PrXQ48wFrwrsrXSslZ0LSB4= =VU1d -----END PGP SIGNATURE-----



More information about the Python-Dev mailing list