]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
count keyword only arguments as part of the total
authorBenjamin Peterson <benjamin@python.org>
Sun, 21 Mar 2010 21:16:24 +0000 (21:16 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 21 Mar 2010 21:16:24 +0000 (21:16 +0000)
Lib/test/test_extcall.py
Python/ceval.c

index a5af50b7206ac9bef8140b728a0f554b3e56f596..cf882a5650ac6c7bbd80c7bf7f6d2927288022db 100644 (file)
@@ -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
index 22c61550bf908aa572388721f6d6569b2cfd89e4..0bd785b57c0635cc23bb9d7890721b1e74cf324e 100644 (file)
@@ -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;
                        }