mirror of
https://github.com/python/cpython.git
synced 2025-08-16 23:01:34 +00:00
Correct handling of functions with only kwarg args in getcallargs (closes #11256)
A patch from Daniel Urban.
This commit is contained in:
parent
41a9ec9003
commit
77d466079a
3 changed files with 25 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue