diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-03-28 17:42:35 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-03-28 17:42:35 -0500 |
commit | 1df78c8e6e03b70a3ad3934355a85b622346087a (patch) | |
tree | c14b1fb229edd6f5ad46989e530fe0c264605a19 /Lib/inspect.py | |
parent | fe55783505943538f0f0edb8238c0d709190a29e (diff) | |
parent | 6a2638b1637bd7f79f55def97df20cfccff02509 (diff) | |
download | cpython-git-1df78c8e6e03b70a3ad3934355a85b622346087a.tar.gz |
merge 3.2
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index aa951d83e2..4899cbf9f0 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -944,8 +944,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 or kwonlyargs: + if num_pos: + # XXX: We should use num_pos, but Python also uses num_total: + raise TypeError('%s() takes exactly 0 positional arguments ' + '(%d given)' % (f_name, num_total)) + else: + raise TypeError('%s() takes no arguments (%d given)' % + (f_name, num_total)) for arg in itertools.chain(args, kwonlyargs): if arg in named: |