[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

Greg Ewing greg.ewing at canterbury.ac.nz
Fri May 21 03:23:15 CEST 2010


Floris Bruynooghe wrote:

> Not having looked at the code I don't know how hard it is for the code
> that raises this traceback to notice if it's a bound or unbound method
> tough.

The way things currently work, it would be quite difficult.
The exception is raised when attempting to call the function
underlying the bound method, at which point it can't be
distinguished from any other way of calling it.

However, it could be made to raise a special subclass of
TypeError that the bound method wrapper could catch and
replace with its own exception.

-- 
Greg


More information about the Python-Dev mailing list