[New-bugs-announce] [issue11256] inspect.getcallargs raises TypeError on valid arguments

Daniel Urban report at bugs.python.org
Sun Feb 20 13:11:10 CET 2011


New submission from Daniel Urban <urban.dani+py at gmail.com>:

inspect.getcallargs raises TypeError if given a function with only **kwargs, and some keyword arguments:

Python 3.3a0 (py3k:88451, Feb 20 2011, 12:37:22) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> from inspect import getcallargs
>>> 
>>> def f(**kwargs): pass
... 
>>> f(a=1, b=2)
>>> 
>>> getcallargs(f, a=1, b=2)
Traceback (most recent call last):
    ...
TypeError: f() takes no arguments (2 given)


In line 946 of inspect.py the "num_args == 0 and num_total" condition is true: the function expects 0 positional arguments and got more than zero arguments, but in this case these are keyword arguments, so it shouldn't raise TypeError.

----------
components: Library (Lib)
messages: 128902
nosy: benjamin.peterson, durban, gsakkis
priority: normal
severity: normal
status: open
title: inspect.getcallargs raises TypeError on valid arguments
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

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


More information about the New-bugs-announce mailing list