mirror of
https://github.com/python/cpython.git
synced 2024-11-26 03:14:27 +08:00
count keyword only arguments as part of the total
This commit is contained in:
parent
f3b7a25a21
commit
afcee8b78d
@ -280,6 +280,12 @@ The number of arguments passed in includes keywords:
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: f() takes exactly 1 argument (5 given)
|
||||
>>> def f(a, *, kw):
|
||||
... pass
|
||||
>>> f(6, 4, kw=4)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: f() takes exactly 2 arguments (3 given)
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
@ -3078,8 +3078,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||
"argument%s (%d given)",
|
||||
co->co_name,
|
||||
defcount ? "at most" : "exactly",
|
||||
co->co_argcount,
|
||||
co->co_argcount == 1 ? "" : "s",
|
||||
total_args,
|
||||
total_args == 1 ? "" : "s",
|
||||
argcount + kwcount);
|
||||
goto fail;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user