Re: [Python-Dev] Error message for wrong number of arguments

On 2018-07-30 20:22, Chris Barker wrote:
is it possible for the interpreter to know when this error is generated that this is a bound method expecting a "self", rather than an arbitrary function with n parameters?
That would be quite hard. The error message is generated by the underlying function. At that point, the information of how it was called (as bound method or not) is already gone. Jeroen.

On Mon, Jul 30, 2018 at 11:39 AM, Jeroen Demeyer <J.Demeyer@ugent.be> wrote:
On 2018-07-30 20:22, Chris Barker wrote:
is it possible for the interpreter to know when this error is generated that this is a bound method expecting a "self", rather than an arbitrary function with n parameters?
That would be quite hard. The error message is generated by the underlying function. At that point, the information of how it was called (as bound method or not) is already gone.
Thanks, I figured as much. Oh well. This is a serious usability issue -- but what can you do? -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov

Hi, On 30 July 2018 at 22:19, Chris Barker via Python-Dev <python-dev@python.org> wrote:
Oh well. This is a serious usability issue -- but what can you do?
I think that argument clinic knows if the built-in function is supposed to be a method or a function. It doesn't look too hard to add a new flag METH_IS_METHOD or something, which would be taken in consideration in the common cases, and which can be added manually OR used automatically by argument clinic. This would not be a 100% solution out of the box, but if the new wording is right, it shouldn't be a problem. A bientôt, Armin.

On Wed, Aug 1, 2018 at 2:40 PM, Armin Rigo <armin.rigo@gmail.com> wrote:
On 30 July 2018 at 22:19, Chris Barker via Python-Dev <python-dev@python.org> wrote:
Oh well. This is a serious usability issue -- but what can you do?
I think that argument clinic knows if the built-in function is supposed to be a method or a function. It doesn't look too hard to add a new flag METH_IS_METHOD or something, which would be taken in consideration in the common cases, and which can be added manually OR used automatically by argument clinic. This would not be a 100% solution out of the box, but if the new wording is right, it shouldn't be a problem.
But can you do the same thing with pure-python methods? After all, this thread started with trying ot unify what error folks get regardless of how the method was written. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov

On 08/01/2018 02:40 PM, Armin Rigo wrote:
I think that argument clinic knows if the built-in function is supposed to be a method or a function.
Yes, Argument Clinic knows. Clinic's "Function" instances have a "cls" member, and if that's set to a Clinic "Class" instance--and it's not one of the special methods like new or init--then it's a normal method.
It doesn't look too hard to add a new flag METH_IS_METHOD or something, which would be taken in consideration in the common cases, and which can be added manually OR used automatically by argument clinic.
Yes, Clinic could easily automatically generate such a flag. //arry/
participants (4)
-
Armin Rigo
-
Chris Barker
-
Jeroen Demeyer
-
Larry Hastings