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

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Oct 7 22:34:15 EDT 2003


> >   TypeError: MyStuff.SomeClass.foo() takes exactly 1 argument (2
> >given)
> 
> 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".

Perhaps. I had the idea that methods already had some notion of
the name of the class they were defined in, but maybe that's
only bound methods. In any case, I think it would be worth
making this change.

> Don't tracebacks give line number and file?

Yes, but the exception occurs just *before* the function is entered,
so the traceback stops one level short of showing you where the
function being called is defined! That's what makes this problem
so annoying.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-Dev mailing list