[New-bugs-announce] [issue6474] Inconsistent TypeError message on function calls with wrong number of arguments

Hagen Fürstenau report at bugs.python.org
Mon Jul 13 16:36:45 CEST 2009


New submission from Hagen Fürstenau <hfuerstenau at gmx.net>:

I think the following error messages are inconsistent and confusing:

>>> def f(a, b): pass
...
>>> f(a=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() takes exactly 2 non-keyword positional arguments (1 given)
>>> f(b=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() takes exactly 2 non-keyword positional arguments (0 given)


Strictly speaking, no positional arguments are given in either case, so
it should say "(0 given)" in both cases. On the other hand, the given
keyword arguments are filled into the positional argument slots, so
stating something like "(1 missing)" or "(1 unspecified)" in both cases
seems to make more sense. Any opinions?

----------
components: Interpreter Core
messages: 90485
nosy: hagen
severity: normal
status: open
title: Inconsistent TypeError message on function calls with wrong number of arguments
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6474>
_______________________________________


More information about the New-bugs-announce mailing list