Skip to content

bpo-30600: Fix error messages (condition order in Argument Clinic) #2051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Lib/test/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ def test_varargs2_kw(self):
msg = r"__contains__\(\) takes no keyword arguments"
self.assertRaisesRegex(TypeError, msg, {}.__contains__, x=2, y=2)

def test_varargs3_kw(self):
msg = r"bool\(\) takes no keyword arguments"
self.assertRaisesRegex(TypeError, msg, bool, x=2)

def test_varargs4_kw(self):
msg = r"^index\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, [].index, x=2)

def test_varargs5_kw(self):
msg = r"^hasattr\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, hasattr, x=2)

def test_oldargs0_1(self):
msg = r"keys\(\) takes no arguments \(1 given\)"
self.assertRaisesRegex(TypeError, msg, {}.keys, 0)
Expand Down
40 changes: 20 additions & 20 deletions Modules/_io/clinic/bufferedio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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]*/
40 changes: 20 additions & 20 deletions Modules/_io/clinic/bytesio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]*/
22 changes: 11 additions & 11 deletions Modules/_io/clinic/fileio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]*/
20 changes: 10 additions & 10 deletions Modules/_io/clinic/iobase.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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]*/
Loading