Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: 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. Added file: http://bugs.python.org/file9933/issue2516poc1.diff __________________________________ 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