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/Modules/clinic/_cryptmodule.c.h b/Modules/clinic/_cryptmodule.c.h
index 3e536c1..0c9d237 100644
--- a/Modules/clinic/_cryptmodule.c.h
+++ b/Modules/clinic/_cryptmodule.c.h
@@ -26,12 +26,12 @@
const char *word;
const char *salt;
- if (!_PyArg_ParseStack(args, nargs, "ss:crypt",
- &word, &salt)) {
+ if (!_PyArg_NoStackKeywords("crypt", kwnames)) {
goto exit;
}
- if (!_PyArg_NoStackKeywords("crypt", kwnames)) {
+ if (!_PyArg_ParseStack(args, nargs, "ss:crypt",
+ &word, &salt)) {
goto exit;
}
return_value = crypt_crypt_impl(module, word, salt);
@@ -39,4 +39,4 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=3fd5d3625a6f32fe input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ebdc6b6a5dec4539 input=a9049054013a1b77]*/