Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue22652>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to