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 serhiy.storchaka
Recipients cool-RR, emptysquare, r.david.murray, serhiy.storchaka, terry.reedy, ztane
Date 2020-05-15.13:06:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589547983.25.0.556902264863.issue22652@roundup.psfhosted.org>
In-reply-to
Content
First, the code for checking arguments was significantly changed in recent versions. So if we are going to make these changes the patch should be not just rebased, but rewritten from zero.

Second, the error messages for wrong number of positional arguments are more diverse.

>>> def func(a, b=1): pass
... 
>>> func()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: func() missing 1 required positional argument: 'a'
>>> func(1, 2, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: func() takes from 1 to 2 positional arguments but 3 were given

It differs when you pass less positional arguments than expected, and when there are optional positional parameters.

Third, when you pass incorrect number of keyword arguments, you get error either about missed keyword arguments (they names, not count), or about an unexpected keyword argument (with its name).

Forth, if you change error messages for Python implemented functions, don't forget about functions implemented in C. Those which use PyArg_ParseTupleAndKeywords (and variants), those which use Argument Clinic, and special cases like print(), sorted(), max().

Personally I think that the current error message is correct and complete. But if you want to improve it, remember that additional information should be correct, useful and consistent across different types of functions. Also, too verbose error message can have negative effect on comprehension. It should provide information necessary to identify the source of the error and do not distract from it.
History
Date User Action Args
2020-05-15 13:06:23serhiy.storchakasetrecipients: + serhiy.storchaka, terry.reedy, r.david.murray, cool-RR, ztane, emptysquare
2020-05-15 13:06:23serhiy.storchakasetmessageid: <1589547983.25.0.556902264863.issue22652@roundup.psfhosted.org>
2020-05-15 13:06:23serhiy.storchakalinkissue22652 messages
2020-05-15 13:06:21serhiy.storchakacreate