msg = r"^from_bytes\(\) takes at most 2 positional arguments \(3 given\)"
self.assertRaisesRegex(TypeError, msg, int.from_bytes, b'a', 'little', False)
+ def test_varargs4(self):
+ msg = r"get expected at least 1 argument, got 0"
+ self.assertRaisesRegex(TypeError, msg, {}.get)
+
+ def test_varargs5(self):
+ msg = r"getattr expected at least 2 arguments, got 0"
+ self.assertRaisesRegex(TypeError, msg, getattr)
+
+ def test_varargs6(self):
+ msg = r"input expected at most 1 argument, got 2"
+ self.assertRaisesRegex(TypeError, msg, input, 1, 2)
+
+ def test_varargs7(self):
+ msg = r"get expected at most 2 arguments, got 3"
+ self.assertRaisesRegex(TypeError, msg, {}.get, 1, 2, 3)
+
def test_varargs1_kw(self):
msg = r"__contains__\(\) takes no keyword arguments"
self.assertRaisesRegex(TypeError, msg, {}.__contains__, x=2)
if (name != NULL)
PyErr_Format(
PyExc_TypeError,
- "%.200s expected %s%zd arguments, got %zd",
- name, (min == max ? "" : "at least "), min, nargs);
+ "%.200s expected %s%zd argument%s, got %zd",
+ name, (min == max ? "" : "at least "), min, min == 1 ? "" : "s", nargs);
else
PyErr_Format(
PyExc_TypeError,
if (name != NULL)
PyErr_Format(
PyExc_TypeError,
- "%.200s expected %s%zd arguments, got %zd",
- name, (min == max ? "" : "at most "), max, nargs);
+ "%.200s expected %s%zd argument%s, got %zd",
+ name, (min == max ? "" : "at most "), max, max == 1 ? "" : "s", nargs);
else
PyErr_Format(
PyExc_TypeError,