]> granicus.if.org Git - python/commitdiff
take into account keyword arguments when passing too many args
authorBenjamin Peterson <benjamin@python.org>
Sun, 21 Mar 2010 20:30:30 +0000 (20:30 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 21 Mar 2010 20:30:30 +0000 (20:30 +0000)
Lib/test/test_extcall.py
Python/ceval.c

index bb922c884d6743a3f0b4e9368b461f01dded25d6..950ac28e729129f2bb9e047d072d0f554beb0753 100644 (file)
@@ -279,6 +279,15 @@ A obscure message:
     Traceback (most recent call last):
       ...
     TypeError: f() takes exactly 2 arguments (1 given)
+
+The number of arguments passed in includes keywords:
+
+    >>> def f(a):
+    ...    pass
+    >>> f(6, a=4, *(1, 2, 3))
+    Traceback (most recent call last):
+      ...
+    TypeError: f() takes exactly 1 argument (5 given)
 """
 
 import unittest
index 4b0ff7ee2272a88072047f3ee37c20705be6aff5..339a35163659b7fe946ea7b0462569fceaf80333 100644 (file)
@@ -3060,7 +3060,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                                    defcount ? "at most" : "exactly",
                                    co->co_argcount,
                                    co->co_argcount == 1 ? "" : "s",
-                                   argcount);
+                                   argcount + kwcount);
                                goto fail;
                        }
                        n = co->co_argcount;