mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
take into account keyword arguments when passing too many args
This commit is contained in:
parent
965458931f
commit
bb9d726357
2 changed files with 10 additions and 1 deletions
|
@ -279,6 +279,15 @@ A obscure message:
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
TypeError: f() takes exactly 2 arguments (1 given)
|
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
|
import unittest
|
||||||
|
|
|
@ -3060,7 +3060,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
defcount ? "at most" : "exactly",
|
defcount ? "at most" : "exactly",
|
||||||
co->co_argcount,
|
co->co_argcount,
|
||||||
co->co_argcount == 1 ? "" : "s",
|
co->co_argcount == 1 ? "" : "s",
|
||||||
argcount);
|
argcount + kwcount);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
n = co->co_argcount;
|
n = co->co_argcount;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue