This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients belopolsky, benjamin.peterson, nedbat, rhettinger
Date 2008-04-03.19:46:40
SpamBayes Score 9.0914764e-05
Marked as misclassified No
Message-id <1207252008.63.0.427411744855.issue2516@psf.upfronthosting.co.za>
In-reply-to
Content
I am uploading another work in progress patch because the problem proved
to be more difficult than I thought in the beginning.  The new patch
addresses two issues.

1. a.f(..) -> A.f(a, ..) transformation is performed is several places
in the current code.  I have streamlined CALL_* opcodes processing to
make all calls go through PyObject_Call. This eliminated some
optimizations that can be put back in once the general framework is
accepted.

2. The only solution I could find to fixing reporting from
instancemethod_call was to add expected number of arguments information
to the exception raised in ceval and use it to reraise with a proper
message.  Obviously, putting the necessary info into the argument tuple
 is a hack and prevents reproducing original error messages from the
regular function calls.  I see two alternatives: (a) parsing the error
string to extract the needed information (feels like even a bigger
hack), and (b) creating an ArgumentError subclass of TypeError and have
its instances store needed information in additional attributes (talking
about a canon and a mosquito!)

3. If a solution that requires extra information in an exception is
accepted, PyArg_Parse* functions should be similarly modified to add the
extra info when raising an error.

Finally, let's revisit whether this mosquito deserves to die.  After
all, anyone looking at method definition sees the self argument, so
saying that a.f(1, 2) provides 3 arguments to f() is not such a stretch
of the truth.

It is also possible that I simply fail to see a simpler solution.  It
this case, please enlighten me!

PS: The patch breaks cProfile and several other tests that check error
messages.  I am making it available for discussion only.
History
Date User Action Args
2008-04-03 19:46:48belopolskysetspambayes_score: 9.09148e-05 -> 9.0914764e-05
recipients: + belopolsky, rhettinger, nedbat, benjamin.peterson
2008-04-03 19:46:48belopolskysetspambayes_score: 9.09148e-05 -> 9.09148e-05
messageid: <1207252008.63.0.427411744855.issue2516@psf.upfronthosting.co.za>
2008-04-03 19:46:47belopolskylinkissue2516 messages
2008-04-03 19:46:45belopolskycreate