aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_call.py
diff options
context:
space:
mode:
authorSylvain <sylvain.desodt+github@gmail.com>2017-06-10 06:51:48 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2017-06-10 07:51:48 +0300
commit7445381c606faf20e253da42656db478a4349f8e (patch)
tree49ad79e5347454d1bbfeb1c2d06d3d09fd9b273f /Lib/test/test_call.py
parente5f6e86c48c7b2eb9e1d6a0e72867b4d8b4720f3 (diff)
downloadcpython-7445381c606faf20e253da42656db478a4349f8e.tar.gz
cpython-7445381c606faf20e253da42656db478a4349f8e.zip
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".
Diffstat (limited to 'Lib/test/test_call.py')
-rw-r--r--Lib/test/test_call.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index 1e84b525f70..f46eb2142f1 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -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)