From: Benjamin Peterson Date: Sun, 21 Mar 2010 21:16:24 +0000 (+0000) Subject: count keyword only arguments as part of the total X-Git-Tag: v3.2a1~1364 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=afcee8b78d92a02263ce1eb1015d0933d3e4e377;p=thirdparty%2FPython%2Fcpython.git count keyword only arguments as part of the total --- diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index a5af50b7206a..cf882a5650ac 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -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 diff --git a/Python/ceval.c b/Python/ceval.c index 22c61550bf90..0bd785b57c06 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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; }