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".
diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h
index d9ac39d..893629b 100644
--- a/Objects/clinic/floatobject.c.h
+++ b/Objects/clinic/floatobject.c.h
@@ -58,13 +58,13 @@
PyObject *return_value = NULL;
PyObject *o_ndigits = NULL;
- if (!_PyArg_UnpackStack(args, nargs, "__round__",
- 0, 1,
- &o_ndigits)) {
+ if (!_PyArg_NoStackKeywords("__round__", kwnames)) {
goto exit;
}
- if (!_PyArg_NoStackKeywords("__round__", kwnames)) {
+ if (!_PyArg_UnpackStack(args, nargs, "__round__",
+ 0, 1,
+ &o_ndigits)) {
goto exit;
}
return_value = float___round___impl(self, o_ndigits);
@@ -273,12 +273,12 @@
const char *typestr;
const char *fmt;
- if (!_PyArg_ParseStack(args, nargs, "ss:__set_format__",
- &typestr, &fmt)) {
+ if (!_PyArg_NoStackKeywords("__set_format__", kwnames)) {
goto exit;
}
- if (!_PyArg_NoStackKeywords("__set_format__", kwnames)) {
+ if (!_PyArg_ParseStack(args, nargs, "ss:__set_format__",
+ &typestr, &fmt)) {
goto exit;
}
return_value = float___set_format___impl(type, typestr, fmt);
@@ -313,4 +313,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=dc6b0b67a7e40c93 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b2271e7413b36162 input=a9049054013a1b77]*/