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".
This commit is contained in:
Sylvain 2017-06-10 06:51:48 +02:00 committed by Serhiy Storchaka
parent e5f6e86c48
commit 7445381c60
51 changed files with 1116 additions and 1104 deletions

View file

@ -204,13 +204,13 @@ _multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, Py
PyObject *return_value = NULL;
PyObject *sizeobj = Py_None;
if (!_PyArg_UnpackStack(args, nargs, "read",
0, 1,
&sizeobj)) {
if (!_PyArg_NoStackKeywords("read", kwnames)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("read", kwnames)) {
if (!_PyArg_UnpackStack(args, nargs, "read",
0, 1,
&sizeobj)) {
goto exit;
}
return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);
@ -237,13 +237,13 @@ _multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self
PyObject *return_value = NULL;
PyObject *sizeobj = Py_None;
if (!_PyArg_UnpackStack(args, nargs, "readline",
0, 1,
&sizeobj)) {
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
if (!_PyArg_UnpackStack(args, nargs, "readline",
0, 1,
&sizeobj)) {
goto exit;
}
return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);
@ -270,13 +270,13 @@ _multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *sel
PyObject *return_value = NULL;
PyObject *sizehintobj = Py_None;
if (!_PyArg_UnpackStack(args, nargs, "readlines",
0, 1,
&sizehintobj)) {
if (!_PyArg_NoStackKeywords("readlines", kwnames)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("readlines", kwnames)) {
if (!_PyArg_UnpackStack(args, nargs, "readlines",
0, 1,
&sizehintobj)) {
goto exit;
}
return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);
@ -342,4 +342,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
/*[clinic end generated code: output=26710ffd4b3c7d7e input=a9049054013a1b77]*/
/*[clinic end generated code: output=12192026a9d55d48 input=a9049054013a1b77]*/