Commit afcee8b7 authored by Benjamin Peterson's avatar Benjamin Peterson

count keyword only arguments as part of the total

parent f3b7a25a
...@@ -280,6 +280,12 @@ The number of arguments passed in includes keywords: ...@@ -280,6 +280,12 @@ The number of arguments passed in includes keywords:
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: f() takes exactly 1 argument (5 given) 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 import sys
......
...@@ -3078,8 +3078,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, ...@@ -3078,8 +3078,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
"argument%s (%d given)", "argument%s (%d given)",
co->co_name, co->co_name,
defcount ? "at most" : "exactly", defcount ? "at most" : "exactly",
co->co_argcount, total_args,
co->co_argcount == 1 ? "" : "s", total_args == 1 ? "" : "s",
argcount + kwcount); argcount + kwcount);
goto fail; goto fail;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment