Correct handling of functions with only kwarg args in getcallargs (closes #11256)

A patch from Daniel Urban.
This commit is contained in:
Benjamin Peterson 2011-03-28 17:32:31 -05:00
parent 41a9ec9003
commit 77d466079a
3 changed files with 25 additions and 2 deletions

View file

@ -943,8 +943,14 @@ def getcallargs(func, *positional, **named):
f_name, 'at most' if defaults else 'exactly', num_args,
'arguments' if num_args > 1 else 'argument', num_total))
elif num_args == 0 and num_total:
raise TypeError('%s() takes no arguments (%d given)' %
(f_name, num_total))
if varkw:
if num_pos:
# XXX: We should use num_pos, but Python also uses num_total:
raise TypeError('%s() takes exactly 0 arguments '
'(%d given)' % (f_name, num_total))
else:
raise TypeError('%s() takes no arguments (%d given)' %
(f_name, num_total))
for arg in args:
if isinstance(arg, str) and arg in named:
if is_assigned(arg):