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 <>
In-reply-to <>
On Thu, Apr 3, 2008 at 9:39 PM, Raymond Hettinger
<> wrote:

> It's definitely a bug

What would you say to the following:

def f(x):
class X:
    xf = f

x = X()

--> 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.
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