2007-03-21

Informal poll: interface of exceptions

I made three mistakes when removing indexing/slicing on exceptions. When I came across ``exc[0]`` I translated it to ``exc.message`` instead of ``exc.args[0]``. There is an important difference, though, between using 'message' and 'args' as the former can be the empty string while args[0] has a value if more than a single argument is passed in. I had not even realized I had made the mistake until Guido pointed it out to me.

With this subtlety, along with how painful it will be to remove 'args' from exceptions (which I have done for the core and anyone at the PyCon sprint can tell you frustrated me to no end), my question is would people miss 'message'? As of right now it has odd semantics because it was added in 2.5 in hopes of removing 'args' and having exceptions only accept a single argument by default, thus we didn't want people to rely on 'message' and think that only one argument was passed in. But if 'args' ends up staying because the transition off of it cannot be done reasonably then is 'message' even worth keeping? The attribute could change to just args[0], but that does not seem useful.

If you happen to have an opinion please leave a comment.