[issue11256] inspect.getcallargs raises TypeError on valid arguments

Daniel Urban report at bugs.python.org
Sun Feb 20 14:32:20 CET 2011


Daniel Urban <urban.dani+py at gmail.com> added the comment:

Here is a patch. It also includes tests that would have detected this bug. It also corrects a case when getcallargs raised an exception with a different message (there are tests also for this):

>>> def f(**kwargs): pass
... 
>>> f(1, a=2)
Traceback (most recent call last):
    ...
TypeError: f() takes exactly 0 positional arguments (2 given)
>>> 
>>> getcallargs(f, 1, a=2)
Traceback (most recent call last):
    ...
TypeError: f() takes no arguments (2 given)

There is a comment in the patch about this case: the message given by Python is also incorrect, because it says that 2 positional arguments are given, but there was only 1 positional argument (the other was a keyword argument).  The patch currently handles this case by producing the same (incorrect) message as Python.

----------
keywords: +patch
Added file: http://bugs.python.org/file20805/issue11256.diff

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


More information about the Python-bugs-list mailing list