only take into account positional arguments count in related error messages
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index cf882a5..c31e920 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -279,13 +279,13 @@
>>> f(6, a=4, *(1, 2, 3))
Traceback (most recent call last):
...
- TypeError: f() takes exactly 1 argument (5 given)
+ TypeError: f() takes exactly 1 positional 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)
+ TypeError: f() takes exactly 1 positional argument (3 given)
"""
import sys
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
index 6a88b3d..bdcc4c6 100644
--- a/Lib/test/test_keywordonlyarg.py
+++ b/Lib/test/test_keywordonlyarg.py
@@ -73,6 +73,14 @@
fundef3 += "lastarg):\n pass\n"
compile(fundef3, "<test>", "single")
+ def testTooManyPositionalErrorMessage(self):
+ def f(a, b=None, *, c=None):
+ pass
+ with self.assertRaises(TypeError) as exc:
+ f(1, 2, 3)
+ expected = "f() takes at most 2 positional arguments (3 given)"
+ self.assertEqual(str(exc.exception), expected)
+
def testSyntaxErrorForFunctionCall(self):
self.assertRaisesSyntaxError("f(p, k=1, p2)")
self.assertRaisesSyntaxError("f(p, k1=50, *(1,2), k1=100)")