Chris Jerdonek added the comment:
TypeError: f() missing 1 required positional argument: 'a'
The error message for round(), for example, has a different form:
round()
TypeError: Required argument 'number' (pos 1) not found
It would be good if these had the same form.
--
New submission from Ezio Melotti:
This came up in #16515.
While using PyArg_UnpackTuple to parse the positional arguments in a function
that receives both positional and keyword arguments, the error message returned
when the number of arguments is incorrect is misleading, e.g.:
max(foo=1)
Changes by Mark Dickinson dicki...@gmail.com:
--
nosy: +mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16543
___
___
Serhiy Storchaka added the comment:
+(min == 1 ? : s), l);
In second part of patch should be max. Reformat the code so that `min` and
`(min == 1 ? : s)` will be in one line and it will be more clear.
--
nosy: +serhiy.storchaka
Mark Dickinson added the comment:
Now that I look at uses of PyArg_UnpackTuple, I'm wondering whether this needs
to be fixed at all. Apart from `max` and `min`, do you know of any other cases
where this gives a misleading error message?
Almost all the uses I can find are for simple
Mark Dickinson added the comment:
Of course, the 'arguments' - 'argument' fix would still be nice to have.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16543
___
Ezio Melotti added the comment:
do you know of any other cases where this gives a misleading error message?
Actually my concern was about cases where the new error might be
wrong/misleading, but I haven't checked yet. If there are no such cases I
think we should fix it; the error message
Mark Dickinson added the comment:
One more thing: I'm not sure this is the right terminology. Here we're using
'positional' to refer to parameters that PEP 362 calls POSITIONAL_ONLY,
whereas the regular TypeErrors (e.g. produced for user-defined functions) use
'positional' to mean what PEP
Mark Dickinson added the comment:
If there are no such cases I think we should fix it.
Okay, but what exactly is this fixing? I can't find any examples apart from
max and min where the new error messages seem any better than the old. Your
first message talks about a function that receives
Ezio Melotti added the comment:
Okay, but what exactly is this fixing?
If the function parses positional args, it should say so in the error message.
If the function is never used (except for min/max) or if the error is never
reported, then we have a different problem.
Even if this code
Changes by Chris Jerdonek chris.jerdo...@gmail.com:
--
nosy: +chris.jerdonek
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16543
___
___
Chris Jerdonek added the comment:
Here we're using 'positional' to refer to parameters that PEP 362 calls
POSITIONAL_ONLY, whereas the regular TypeErrors (e.g. produced for
user-defined functions) use 'positional' to mean what PEP 362 calls
POSITIONAL_OR_KEYWORD.
Here the error message
Chris Jerdonek added the comment:
This can be fixed by adding positional before arguments in the error
message.
Do we know for sure that the values in the args argument in a call to
PyArg_UnpackTuple always correspond to the positional arguments of a call to a
Python function? Can
Mark Dickinson added the comment:
Here the error message is about positional arguments, which are
different from parameters.
Okay. So is it also planned to change the existing error messages for
user-defined functions? E.g.:
def f(a, b=1):
... pass
...
f()
Traceback (most recent
Ezio Melotti added the comment:
Maybe we should follow a more systematic approach and collect the different
errors raised in the different situations, and then come up with error messages
that are accurate and follow the terminology that we are adopting in #15990.
--
Chris Jerdonek added the comment:
TypeError: f() missing 1 required positional argument: 'a'
Yes, I think this should also be changed because passing a as a keyword
argument is okay:
f(a=1)
I would suggest something like--
TypeError: f() missing argument for parameter 'a'
--
Ezio Melotti added the comment:
I would be fine with just dropping positional there, and say required
argument. With no further specification it means the default type of
argument, i.e. positional or keyword. See also the end of msg170876.
--
___
Chris Jerdonek added the comment:
TypeError: f() missing 1 required positional argument: 'a'
By the way, changing this message is the subject of issue 16520 (which should
probably be retitled).
--
___
Python tracker rep...@bugs.python.org
Ezio Melotti added the comment:
#16520 could be assimilated by this issue, if we decide to widen its scope as I
suggested in msg176229.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16543
Mark Dickinson added the comment:
+1 to msg176229
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16543
___
___
Python-bugs-list mailing list
Chris Jerdonek added the comment:
I would keep any global discussion (for decision and coordination purposes)
as part of a single meta-issue, but retain individual instances that need to be
corrected as separate issues. I don't think we should try to fix them all as
part of one patch or
Ezio Melotti added the comment:
Using this as meta-issue is fine -- there are already enough issues :)
The issues can probably be fixed in a single patch too, since it should just be
a matter of changing the text of a few error messages.
--
___
22 matches
Mail list logo