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/_ssl.c.h b/Modules/clinic/_ssl.c.h
index 4a053d4..ece3088 100644
--- a/Modules/clinic/_ssl.c.h
+++ b/Modules/clinic/_ssl.c.h
@@ -71,12 +71,12 @@
PyObject *return_value = NULL;
int binary_mode = 0;
- if (!_PyArg_ParseStack(args, nargs, "|p:peer_certificate",
- &binary_mode)) {
+ if (!_PyArg_NoStackKeywords("peer_certificate", kwnames)) {
goto exit;
}
- if (!_PyArg_NoStackKeywords("peer_certificate", kwnames)) {
+ if (!_PyArg_ParseStack(args, nargs, "|p:peer_certificate",
+ &binary_mode)) {
goto exit;
}
return_value = _ssl__SSLSocket_peer_certificate_impl(self, binary_mode);
@@ -772,12 +772,12 @@
PyObject *return_value = NULL;
int len = -1;
- if (!_PyArg_ParseStack(args, nargs, "|i:read",
- &len)) {
+ if (!_PyArg_NoStackKeywords("read", kwnames)) {
goto exit;
}
- if (!_PyArg_NoStackKeywords("read", kwnames)) {
+ if (!_PyArg_ParseStack(args, nargs, "|i:read",
+ &len)) {
goto exit;
}
return_value = _ssl_MemoryBIO_read_impl(self, len);
@@ -862,12 +862,12 @@
Py_buffer view = {NULL, NULL};
double entropy;
- if (!_PyArg_ParseStack(args, nargs, "s*d:RAND_add",
- &view, &entropy)) {
+ if (!_PyArg_NoStackKeywords("RAND_add", kwnames)) {
goto exit;
}
- if (!_PyArg_NoStackKeywords("RAND_add", kwnames)) {
+ if (!_PyArg_ParseStack(args, nargs, "s*d:RAND_add",
+ &view, &entropy)) {
goto exit;
}
return_value = _ssl_RAND_add_impl(module, &view, entropy);
@@ -1180,4 +1180,4 @@
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
-/*[clinic end generated code: output=53cd9100580b45a2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2ab0e4fdb2d2acbc input=a9049054013a1b77]*/