Author belopolsky
Recipients belopolsky, benjamin.peterson, gvanrossum, nedbat, rhettinger
Date 2008-04-04.14:54:52
SpamBayes Score 0.000421196
Marked as misclassified No
Message-id <d38f5330804040754s45ee192ha308e7818be8c1f4@mail.gmail.com>
In-reply-to <1207273198.91.0.597175319604.issue2516@psf.upfronthosting.co.za>
Content
On Thu, Apr 3, 2008 at 9:39 PM, Raymond Hettinger
<report@bugs.python.org> 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.
History
Date User Action Args
2008-04-04 15:11:05belopolskysetspambayes_score: 0.000421196 -> 0.000421196
recipients: + belopolsky, gvanrossum, rhettinger, nedbat, benjamin.peterson
2008-04-04 14:54:54belopolskylinkissue2516 messages
2008-04-04 14:54:52belopolskycreate