More informative error messages (Re: [Python-Dev] Efficient predicates for the standard library)

Phillip J. Eby pje at
Tue Oct 7 11:44:50 EDT 2003

At 01:33 PM 10/7/03 +1300, Greg Ewing wrote:
>While we're on the subject of error messages, I'd like to
>point out another one that could be improved. Often one
>sees things like
>   TypeError: foo() takes exactly 1 argument (2 given)
>In the case where foo() is a method of some class, and there
>are various versions of foo() defined in various superclasses,
>it's sometimes hard to tell exactly *which* foo it was trying
>to call. It would be much more useful if the module and
>class names were included in the error message, e.g.
>   TypeError: takes exactly 1 argument (2

AFAICT, this would at least require a compiler change, and a change to the 
layout of code objects, so that a code object would know its "dotted name".

>The same goes for function names quoted in the traceback.

Don't tracebacks give line number and file?

More information about the Python-Dev mailing list