bpo-30600: Fix error messages (condition order in Argument Clinic) (#2051)

The function '_PyArg_ParseStack()' and
'_PyArg_UnpackStack' were failing (with error
"XXX() takes Y argument (Z given)") before
the function '_PyArg_NoStackKeywords()' was called.
Thus, the latter did not raise its more meaningful
error : "XXX() takes no keyword arguments".
This commit is contained in:
Sylvain 2017-06-10 06:51:48 +02:00 committed by Serhiy Storchaka
parent e5f6e86c48
commit 7445381c60
51 changed files with 1116 additions and 1104 deletions

View file

@ -148,6 +148,18 @@ class CFunctionCallsErrorMessages(unittest.TestCase):
msg = r"__contains__\(\) takes no keyword arguments"
self.assertRaisesRegex(TypeError, msg, {}.__contains__, x=2, y=2)
def test_varargs3_kw(self):
msg = r"bool\(\) takes no keyword arguments"
self.assertRaisesRegex(TypeError, msg, bool, x=2)
def test_varargs4_kw(self):
msg = r"^index\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, [].index, x=2)
def test_varargs5_kw(self):
msg = r"^hasattr\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, hasattr, x=2)
def test_oldargs0_1(self):
msg = r"keys\(\) takes no arguments \(1 given\)"
self.assertRaisesRegex(TypeError, msg, {}.keys, 0)