Alexander Belopolsky <[EMAIL PROTECTED]> added the comment:
On Thu, Apr 3, 2008 at 9:39 PM, Raymond Hettinger
<[EMAIL PROTECTED]> wrote:
> It's definitely a bug
What would you say to the following:
def f(x):
pass
class X:
xf = f
x = X()
x.xf(1,2)
--> TypeError: f() takes exactly 1 argument (3 given)
Is this correct?
..
> I was hoping for something along the lines of functions raising an
> ArgumentError (a new subclass of TypeError) that could be trapped by
> the __call__ slot for bound methods and then reraised with a new
> argument count.
This would be my first choice for a clean solution as well. Since it
will require a change to the exception hierarchy, should we discuss a
modification to PEP 348 on python-dev? I would rather finish the
patch first and then make a concrete proposal.
> The key is to find a *very* lightweight and minimal solution;
.. according to what metric? Are you talking about the amount of code
that needs to be changed, the number of API changes or run-time
overhead? I don't think run-time overhead is an issue: argument
errors are rarely used for flow control because it is hard to predict
what a failed attempt to call a function would do.
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2516>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com