diff options
author | Sylvain <sylvain.desodt+github@gmail.com> | 2017-06-10 04:51:48 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-10 04:51:48 (GMT) |
commit | 7445381c606faf20e253da42656db478a4349f8e (patch) | |
tree | 49ad79e5347454d1bbfeb1c2d06d3d09fd9b273f /Modules/_io/clinic | |
parent | e5f6e86c48c7b2eb9e1d6a0e72867b4d8b4720f3 (diff) | |
download | cpython-7445381c606faf20e253da42656db478a4349f8e.zip cpython-7445381c606faf20e253da42656db478a4349f8e.tar.gz cpython-7445381c606faf20e253da42656db478a4349f8e.tar.bz2 |
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".
Diffstat (limited to 'Modules/_io/clinic')
-rw-r--r-- | Modules/_io/clinic/bufferedio.c.h | 40 | ||||
-rw-r--r-- | Modules/_io/clinic/bytesio.c.h | 40 | ||||
-rw-r--r-- | Modules/_io/clinic/fileio.c.h | 22 | ||||
-rw-r--r-- | Modules/_io/clinic/iobase.c.h | 20 | ||||
-rw-r--r-- | Modules/_io/clinic/stringio.c.h | 26 | ||||
-rw-r--r-- | Modules/_io/clinic/textio.c.h | 28 | ||||
-rw-r--r-- | Modules/_io/clinic/winconsoleio.c.h | 8 |
7 files changed, 92 insertions, 92 deletions
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h index c910dce..ae3d484 100644 --- a/Modules/_io/clinic/bufferedio.c.h +++ b/Modules/_io/clinic/bufferedio.c.h @@ -102,12 +102,12 @@ _io__Buffered_peek(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject * PyObject *return_value = NULL; Py_ssize_t size = 0; - if (!_PyArg_ParseStack(args, nargs, "|n:peek", - &size)) { + if (!_PyArg_NoStackKeywords("peek", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("peek", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|n:peek", + &size)) { goto exit; } return_value = _io__Buffered_peek_impl(self, size); @@ -133,12 +133,12 @@ _io__Buffered_read(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject * PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _Py_convert_optional_to_ssize_t, &n)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read", + _Py_convert_optional_to_ssize_t, &n)) { goto exit; } return_value = _io__Buffered_read_impl(self, n); @@ -164,12 +164,12 @@ _io__Buffered_read1(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_ParseStack(args, nargs, "|n:read1", - &n)) { + if (!_PyArg_NoStackKeywords("read1", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read1", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|n:read1", + &n)) { goto exit; } return_value = _io__Buffered_read1_impl(self, n); @@ -257,12 +257,12 @@ _io__Buffered_readline(buffered *self, PyObject **args, Py_ssize_t nargs, PyObje PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readline", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("readline", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readline", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:readline", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io__Buffered_readline_impl(self, size); @@ -289,12 +289,12 @@ _io__Buffered_seek(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject * PyObject *targetobj; int whence = 0; - if (!_PyArg_ParseStack(args, nargs, "O|i:seek", - &targetobj, &whence)) { + if (!_PyArg_NoStackKeywords("seek", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("seek", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "O|i:seek", + &targetobj, &whence)) { goto exit; } return_value = _io__Buffered_seek_impl(self, targetobj, whence); @@ -320,13 +320,13 @@ _io__Buffered_truncate(buffered *self, PyObject **args, Py_ssize_t nargs, PyObje PyObject *return_value = NULL; PyObject *pos = Py_None; - if (!_PyArg_UnpackStack(args, nargs, "truncate", - 0, 1, - &pos)) { + if (!_PyArg_NoStackKeywords("truncate", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("truncate", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "truncate", + 0, 1, + &pos)) { goto exit; } return_value = _io__Buffered_truncate_impl(self, pos); @@ -500,4 +500,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=3cf3262c9b157dc1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4f7490f82427c63b input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index 559971c..4addaa8 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -169,12 +169,12 @@ _io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwn PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_BytesIO_read_impl(self, size); @@ -204,12 +204,12 @@ _io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kw PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read1", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("read1", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read1", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read1", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_BytesIO_read1_impl(self, size); @@ -240,12 +240,12 @@ _io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readline", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("readline", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readline", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:readline", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_BytesIO_readline_impl(self, size); @@ -276,13 +276,13 @@ _io_BytesIO_readlines(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; PyObject *arg = Py_None; - if (!_PyArg_UnpackStack(args, nargs, "readlines", - 0, 1, - &arg)) { + if (!_PyArg_NoStackKeywords("readlines", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readlines", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "readlines", + 0, 1, + &arg)) { goto exit; } return_value = _io_BytesIO_readlines_impl(self, arg); @@ -347,12 +347,12 @@ _io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; Py_ssize_t size = self->pos; - if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("truncate", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("truncate", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_BytesIO_truncate_impl(self, size); @@ -386,12 +386,12 @@ _io_BytesIO_seek(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwn Py_ssize_t pos; int whence = 0; - if (!_PyArg_ParseStack(args, nargs, "n|i:seek", - &pos, &whence)) { + if (!_PyArg_NoStackKeywords("seek", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("seek", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "n|i:seek", + &pos, &whence)) { goto exit; } return_value = _io_BytesIO_seek_impl(self, pos, whence); @@ -468,4 +468,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=733795434f838b71 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=9e63715414bffb2a input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h index cd5075d..0d9ac61 100644 --- a/Modules/_io/clinic/fileio.c.h +++ b/Modules/_io/clinic/fileio.c.h @@ -213,12 +213,12 @@ _io_FileIO_read(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnam PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_FileIO_read_impl(self, size); @@ -290,12 +290,12 @@ _io_FileIO_seek(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnam PyObject *pos; int whence = 0; - if (!_PyArg_ParseStack(args, nargs, "O|i:seek", - &pos, &whence)) { + if (!_PyArg_NoStackKeywords("seek", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("seek", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "O|i:seek", + &pos, &whence)) { goto exit; } return_value = _io_FileIO_seek_impl(self, pos, whence); @@ -347,13 +347,13 @@ _io_FileIO_truncate(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *return_value = NULL; PyObject *posobj = NULL; - if (!_PyArg_UnpackStack(args, nargs, "truncate", - 0, 1, - &posobj)) { + if (!_PyArg_NoStackKeywords("truncate", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("truncate", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "truncate", + 0, 1, + &posobj)) { goto exit; } return_value = _io_FileIO_truncate_impl(self, posobj); @@ -385,4 +385,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ -/*[clinic end generated code: output=a4044e2d878248d0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2c6a5470100a8f10 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index a6780c2..e869d0d 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -185,12 +185,12 @@ _io__IOBase_readline(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; Py_ssize_t limit = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readline", - _Py_convert_optional_to_ssize_t, &limit)) { + if (!_PyArg_NoStackKeywords("readline", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readline", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:readline", + _Py_convert_optional_to_ssize_t, &limit)) { goto exit; } return_value = _io__IOBase_readline_impl(self, limit); @@ -221,12 +221,12 @@ _io__IOBase_readlines(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObjec PyObject *return_value = NULL; Py_ssize_t hint = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readlines", - _Py_convert_optional_to_ssize_t, &hint)) { + if (!_PyArg_NoStackKeywords("readlines", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readlines", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:readlines", + _Py_convert_optional_to_ssize_t, &hint)) { goto exit; } return_value = _io__IOBase_readlines_impl(self, hint); @@ -260,12 +260,12 @@ _io__RawIOBase_read(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_ParseStack(args, nargs, "|n:read", - &n)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|n:read", + &n)) { goto exit; } return_value = _io__RawIOBase_read_impl(self, n); @@ -291,4 +291,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=d3f59c135231baae input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8361ae8d81d072bf input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h index 2710135..6dd4c5e 100644 --- a/Modules/_io/clinic/stringio.c.h +++ b/Modules/_io/clinic/stringio.c.h @@ -59,12 +59,12 @@ _io_StringIO_read(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_StringIO_read_impl(self, size); @@ -93,12 +93,12 @@ _io_StringIO_readline(stringio *self, PyObject **args, Py_ssize_t nargs, PyObjec PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:readline", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("readline", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readline", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:readline", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_StringIO_readline_impl(self, size); @@ -129,12 +129,12 @@ _io_StringIO_truncate(stringio *self, PyObject **args, Py_ssize_t nargs, PyObjec PyObject *return_value = NULL; Py_ssize_t size = self->pos; - if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("truncate", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("truncate", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io_StringIO_truncate_impl(self, size); @@ -168,12 +168,12 @@ _io_StringIO_seek(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *k Py_ssize_t pos; int whence = 0; - if (!_PyArg_ParseStack(args, nargs, "n|i:seek", - &pos, &whence)) { + if (!_PyArg_NoStackKeywords("seek", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("seek", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "n|i:seek", + &pos, &whence)) { goto exit; } return_value = _io_StringIO_seek_impl(self, pos, whence); @@ -302,4 +302,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored)) { return _io_StringIO_seekable_impl(self); } -/*[clinic end generated code: output=03429d95ed7cd92f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=443f5dd99bbbd053 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h index abb80ea..e609eaa 100644 --- a/Modules/_io/clinic/textio.c.h +++ b/Modules/_io/clinic/textio.c.h @@ -271,12 +271,12 @@ _io_TextIOWrapper_read(textio *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *return_value = NULL; Py_ssize_t n = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _Py_convert_optional_to_ssize_t, &n)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read", + _Py_convert_optional_to_ssize_t, &n)) { goto exit; } return_value = _io_TextIOWrapper_read_impl(self, n); @@ -302,12 +302,12 @@ _io_TextIOWrapper_readline(textio *self, PyObject **args, Py_ssize_t nargs, PyOb PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|n:readline", - &size)) { + if (!_PyArg_NoStackKeywords("readline", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("readline", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|n:readline", + &size)) { goto exit; } return_value = _io_TextIOWrapper_readline_impl(self, size); @@ -334,12 +334,12 @@ _io_TextIOWrapper_seek(textio *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *cookieObj; int whence = 0; - if (!_PyArg_ParseStack(args, nargs, "O|i:seek", - &cookieObj, &whence)) { + if (!_PyArg_NoStackKeywords("seek", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("seek", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "O|i:seek", + &cookieObj, &whence)) { goto exit; } return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence); @@ -382,13 +382,13 @@ _io_TextIOWrapper_truncate(textio *self, PyObject **args, Py_ssize_t nargs, PyOb PyObject *return_value = NULL; PyObject *pos = Py_None; - if (!_PyArg_UnpackStack(args, nargs, "truncate", - 0, 1, - &pos)) { + if (!_PyArg_NoStackKeywords("truncate", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("truncate", kwnames)) { + if (!_PyArg_UnpackStack(args, nargs, "truncate", + 0, 1, + &pos)) { goto exit; } return_value = _io_TextIOWrapper_truncate_impl(self, pos); @@ -515,4 +515,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) { return _io_TextIOWrapper_close_impl(self); } -/*[clinic end generated code: output=7d0dc8eae4b725a1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8ffc6d2557c9c620 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h index f694cd8..03ddae3 100644 --- a/Modules/_io/clinic/winconsoleio.c.h +++ b/Modules/_io/clinic/winconsoleio.c.h @@ -220,12 +220,12 @@ _io__WindowsConsoleIO_read(winconsoleio *self, PyObject **args, Py_ssize_t nargs PyObject *return_value = NULL; Py_ssize_t size = -1; - if (!_PyArg_ParseStack(args, nargs, "|O&:read", - _Py_convert_optional_to_ssize_t, &size)) { + if (!_PyArg_NoStackKeywords("read", kwnames)) { goto exit; } - if (!_PyArg_NoStackKeywords("read", kwnames)) { + if (!_PyArg_ParseStack(args, nargs, "|O&:read", + _Py_convert_optional_to_ssize_t, &size)) { goto exit; } return_value = _io__WindowsConsoleIO_read_impl(self, size); @@ -332,4 +332,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */ -/*[clinic end generated code: output=f2a240ec6af12a20 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3bbf6f893a58f476 input=a9049054013a1b77]*/ |