summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic/fileio.c.h
diff options
context:
space:
mode:
authorSylvain <sylvain.desodt+github@gmail.com>2017-06-10 04:51:48 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-06-10 04:51:48 (GMT)
commit7445381c606faf20e253da42656db478a4349f8e (patch)
tree49ad79e5347454d1bbfeb1c2d06d3d09fd9b273f /Modules/_io/clinic/fileio.c.h
parente5f6e86c48c7b2eb9e1d6a0e72867b4d8b4720f3 (diff)
downloadcpython-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/fileio.c.h')
-rw-r--r--Modules/_io/clinic/fileio.c.h22
1 files changed, 11 insertions, 11 deletions
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]*/