[Python-Dev] Patch 532638: Better AttributeError formatting

Tim Peters tim.one@comcast.net
Wed, 20 Mar 2002 21:54:15 -0500


Check it out:

    http://python.org/sf/532638

*Someone* has written a "lazy msg exception class" before in the core, and
it may even have been me.  If it wasn't me, pipe up and give Skip a nudge in
the right direction (OTOH, if it was me, maybe I'll remember tomorrow).

Another good candidate would be a lazy exception msg for IndexError, giving
the index passed in and the actual limit (that also came up on c.l.py over
the last week).

Since AttributeErrors and IndexErrors are overwhelmingly ignored (recall
that IndexError was the only way to terminate a for loop normally via
exhaustion before 2.2), paying to format a message before the string is
provably needed is overwhelmingly a waste of cycles.

Even calling PyErr_Format() to interpolate two strings (as AttributeError
often does today) seems a significant bit of work to throw away routinely.