bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313)

This commit is contained in:
Serhiy Storchaka 2019-01-11 16:01:14 +02:00 committed by GitHub
parent 5485085b32
commit 4fa9591025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 6194 additions and 778 deletions

View File

@ -66,7 +66,12 @@ PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
#define _PyArg_NoPositional(funcname, args) \
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, PyObject *);
PyAPI_FUNC(void) _PyArg_BadArgument(const char *, int, const char *, PyObject *);
PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
Py_ssize_t, Py_ssize_t);
#define _PyArg_CheckPositional(funcname, nargs, min, max) \
(((min) <= (nargs) && (nargs) <= (max)) \
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
#endif

File diff suppressed because it is too large Load Diff

View File

@ -21,11 +21,11 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
_PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
@ -58,11 +58,11 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto1", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "contiguous buffer", arg);
_PyArg_BadArgument("readinto1", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
@ -114,10 +114,30 @@ _io__Buffered_peek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t size = 0;
if (!_PyArg_ParseStack(args, nargs, "|n:peek",
&size)) {
if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
size = ival;
}
skip_optional:
return_value = _io__Buffered_peek_impl(self, size);
exit:
@ -141,10 +161,16 @@ _io__Buffered_read(buffered *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
goto exit;
}
skip_optional:
return_value = _io__Buffered_read_impl(self, n);
exit:
@ -168,10 +194,30 @@ _io__Buffered_read1(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:read1",
&n)) {
if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
n = ival;
}
skip_optional:
return_value = _io__Buffered_read1_impl(self, n);
exit:
@ -197,11 +243,11 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
_PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto_impl(self, &buffer);
@ -234,11 +280,11 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto1", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "contiguous buffer", arg);
_PyArg_BadArgument("readinto1", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto1_impl(self, &buffer);
@ -269,10 +315,16 @@ _io__Buffered_readline(buffered *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io__Buffered_readline_impl(self, size);
exit:
@ -297,10 +349,23 @@ _io__Buffered_seek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *targetobj;
int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
&targetobj, &whence)) {
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
goto exit;
}
targetobj = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
whence = _PyLong_AsInt(args[1]);
if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _io__Buffered_seek_impl(self, targetobj, whence);
exit:
@ -418,7 +483,7 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
_PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_BufferedWriter_write_impl(self, &buffer);
@ -462,10 +527,32 @@ _io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair",
&reader, &writer, &buffer_size)) {
if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) {
goto exit;
}
reader = PyTuple_GET_ITEM(args, 0);
writer = PyTuple_GET_ITEM(args, 1);
if (PyTuple_GET_SIZE(args) < 3) {
goto skip_optional;
}
if (PyFloat_Check(PyTuple_GET_ITEM(args, 2))) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 2));
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
buffer_size = ival;
}
skip_optional:
return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
exit:
@ -504,4 +591,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/
/*[clinic end generated code: output=a85f61f495feff5c input=a9049054013a1b77]*/

View File

@ -169,10 +169,16 @@ _io_BytesIO_read(bytesio *self, PyObject *const *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_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_BytesIO_read_impl(self, size);
exit:
@ -200,10 +206,16 @@ _io_BytesIO_read1(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("read1", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_BytesIO_read1_impl(self, size);
exit:
@ -232,10 +244,16 @@ _io_BytesIO_readline(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_BytesIO_readline_impl(self, size);
exit:
@ -298,11 +316,11 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
_PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_BytesIO_readinto_impl(self, &buffer);
@ -337,10 +355,16 @@ _io_BytesIO_truncate(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("truncate", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_BytesIO_truncate_impl(self, size);
exit:
@ -372,10 +396,39 @@ _io_BytesIO_seek(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t pos;
int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
&pos, &whence)) {
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
pos = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
whence = _PyLong_AsInt(args[1]);
if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit:
@ -450,4 +503,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/
/*[clinic end generated code: output=5c68eb481fa960bf input=a9049054013a1b77]*/

View File

@ -158,11 +158,11 @@ _io_FileIO_readinto(fileio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
_PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_FileIO_readinto_impl(self, &buffer);
@ -219,10 +219,16 @@ _io_FileIO_read(fileio *self, PyObject *const *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_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_FileIO_read_impl(self, size);
exit:
@ -255,7 +261,7 @@ _io_FileIO_write(fileio *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
_PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io_FileIO_write_impl(self, &b);
@ -296,10 +302,23 @@ _io_FileIO_seek(fileio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *pos;
int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
&pos, &whence)) {
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
goto exit;
}
pos = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
whence = _PyLong_AsInt(args[1]);
if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _io_FileIO_seek_impl(self, pos, whence);
exit:
@ -383,4 +402,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=8be0ea9a5ac7aa43 input=a9049054013a1b77]*/
/*[clinic end generated code: output=4cf4e5f0cd656b11 input=a9049054013a1b77]*/

View File

@ -185,10 +185,16 @@ _io__IOBase_readline(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &limit)) {
goto exit;
}
skip_optional:
return_value = _io__IOBase_readline_impl(self, limit);
exit:
@ -217,10 +223,16 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("readlines", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &hint)) {
goto exit;
}
skip_optional:
return_value = _io__IOBase_readlines_impl(self, hint);
exit:
@ -252,10 +264,30 @@ _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:read",
&n)) {
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
n = ival;
}
skip_optional:
return_value = _io__RawIOBase_read_impl(self, n);
exit:
@ -279,4 +311,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__RawIOBase_readall_impl(self);
}
/*[clinic end generated code: output=cde4b0e96a4e69e3 input=a9049054013a1b77]*/
/*[clinic end generated code: output=60e43a7cbd9f314e input=a9049054013a1b77]*/

View File

@ -59,10 +59,16 @@ _io_StringIO_read(stringio *self, PyObject *const *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_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_StringIO_read_impl(self, size);
exit:
@ -89,10 +95,16 @@ _io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_StringIO_readline_impl(self, size);
exit:
@ -121,10 +133,16 @@ _io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("truncate", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io_StringIO_truncate_impl(self, size);
exit:
@ -156,10 +174,39 @@ _io_StringIO_seek(stringio *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t pos;
int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
&pos, &whence)) {
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
pos = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
whence = _PyLong_AsInt(args[1]);
if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _io_StringIO_seek_impl(self, pos, whence);
exit:
@ -286,4 +333,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_seekable_impl(self);
}
/*[clinic end generated code: output=00c3c7a1c6ea6773 input=a9049054013a1b77]*/
/*[clinic end generated code: output=db5e51dcc4dae8d5 input=a9049054013a1b77]*/

View File

@ -251,7 +251,7 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg)
PyObject *text;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("write", "str", arg);
_PyArg_BadArgument("write", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -281,10 +281,16 @@ _io_TextIOWrapper_read(textio *self, PyObject *const *args, Py_ssize_t nargs)
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_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &n)) {
goto exit;
}
skip_optional:
return_value = _io_TextIOWrapper_read_impl(self, n);
exit:
@ -308,10 +314,30 @@ _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs
PyObject *return_value = NULL;
Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:readline",
&size)) {
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
size = ival;
}
skip_optional:
return_value = _io_TextIOWrapper_readline_impl(self, size);
exit:
@ -336,10 +362,23 @@ _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *cookieObj;
int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
&cookieObj, &whence)) {
if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
goto exit;
}
cookieObj = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
whence = _PyLong_AsInt(args[1]);
if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit:
@ -509,4 +548,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/
/*[clinic end generated code: output=8bdd1035bf878d6f input=a9049054013a1b77]*/

View File

@ -158,11 +158,11 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
_PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
_PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
@ -226,10 +226,16 @@ _io__WindowsConsoleIO_read(winconsoleio *self, PyObject *const *args, Py_ssize_t
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_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!_Py_convert_optional_to_ssize_t(args[0], &size)) {
goto exit;
}
skip_optional:
return_value = _io__WindowsConsoleIO_read_impl(self, size);
exit:
@ -265,7 +271,7 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
_PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _io__WindowsConsoleIO_write_impl(self, &b);
@ -338,4 +344,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=4337e8de65915a1e input=a9049054013a1b77]*/
/*[clinic end generated code: output=ab0f0ee8062eecb3 input=a9049054013a1b77]*/

View File

@ -151,7 +151,7 @@ _multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoder
PyLongObject *statelong;
if (!PyLong_Check(arg)) {
_PyArg_BadArgument("setstate", "int", arg);
_PyArg_BadArgument("setstate", 0, "int", arg);
goto exit;
}
statelong = (PyLongObject *)arg;
@ -251,7 +251,7 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoder
PyObject *state;
if (!PyTuple_Check(arg)) {
_PyArg_BadArgument("setstate", "tuple", arg);
_PyArg_BadArgument("setstate", 0, "tuple", arg);
goto exit;
}
state = arg;
@ -422,4 +422,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=a94364d0965adf1d input=a9049054013a1b77]*/
/*[clinic end generated code: output=2ed7030b28a79029 input=a9049054013a1b77]*/

View File

@ -29,7 +29,7 @@ _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg);
_PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _bz2_BZ2Compressor_compress_impl(self, &data);
@ -89,10 +89,22 @@ _bz2_BZ2Compressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("BZ2Compressor", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "|i:BZ2Compressor",
&compresslevel)) {
if (!_PyArg_CheckPositional("BZ2Compressor", PyTuple_GET_SIZE(args), 0, 1)) {
goto exit;
}
if (PyTuple_GET_SIZE(args) < 1) {
goto skip_optional;
}
if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
compresslevel = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0));
if (compresslevel == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _bz2_BZ2Compressor___init___impl((BZ2Compressor *)self, compresslevel);
exit:
@ -178,4 +190,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=8549cccdb82f57d9 input=a9049054013a1b77]*/
/*[clinic end generated code: output=892c6133e97ff840 input=a9049054013a1b77]*/

File diff suppressed because it is too large Load Diff

View File

@ -16,13 +16,30 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("_tuplegetter", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "nO:_tuplegetter",
&index, &doc)) {
if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
goto exit;
}
if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 0));
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
doc = PyTuple_GET_ITEM(args, 1);
return_value = tuplegetter_new_impl(type, index, doc);
exit:
return return_value;
}
/*[clinic end generated code: output=83746071eacc28d3 input=a9049054013a1b77]*/
/*[clinic end generated code: output=51bd572577ca7111 input=a9049054013a1b77]*/

View File

@ -26,8 +26,33 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *word;
const char *salt;
if (!_PyArg_ParseStack(args, nargs, "ss:crypt",
&word, &salt)) {
if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("crypt", 1, "str", args[0]);
goto exit;
}
Py_ssize_t word_length;
word = PyUnicode_AsUTF8AndSize(args[0], &word_length);
if (word == NULL) {
goto exit;
}
if (strlen(word) != (size_t)word_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("crypt", 2, "str", args[1]);
goto exit;
}
Py_ssize_t salt_length;
salt = PyUnicode_AsUTF8AndSize(args[1], &salt_length);
if (salt == NULL) {
goto exit;
}
if (strlen(salt) != (size_t)salt_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = crypt_crypt_impl(module, word, salt);
@ -35,4 +60,4 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=79001dbfdd623ff9 input=a9049054013a1b77]*/
/*[clinic end generated code: output=3f75d4d4be4dddbb input=a9049054013a1b77]*/

View File

@ -149,8 +149,25 @@ _curses_panel_panel_move(PyCursesPanelObject *self, PyObject *const *args, Py_ss
int y;
int x;
if (!_PyArg_ParseStack(args, nargs, "ii:move",
&y, &x)) {
if (!_PyArg_CheckPositional("move", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
y = _PyLong_AsInt(args[0]);
if (y == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
x = _PyLong_AsInt(args[1]);
if (x == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_panel_panel_move_impl(self, y, x);
@ -197,7 +214,7 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg)
PyCursesWindowObject *win;
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
_PyArg_BadArgument("replace", (&PyCursesWindow_Type)->tp_name, arg);
_PyArg_BadArgument("replace", 0, (&PyCursesWindow_Type)->tp_name, arg);
goto exit;
}
win = (PyCursesWindowObject *)arg;
@ -271,7 +288,7 @@ _curses_panel_new_panel(PyObject *module, PyObject *arg)
PyCursesWindowObject *win;
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
_PyArg_BadArgument("new_panel", (&PyCursesWindow_Type)->tp_name, arg);
_PyArg_BadArgument("new_panel", 0, (&PyCursesWindow_Type)->tp_name, arg);
goto exit;
}
win = (PyCursesWindowObject *)arg;
@ -318,4 +335,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _curses_panel_update_panels_impl(module);
}
/*[clinic end generated code: output=4b211b4015e29100 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ac1f56e6c3d4cc57 input=a9049054013a1b77]*/

View File

@ -245,10 +245,23 @@ _curses_window_bkgd(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_
PyObject *ch;
long attr = A_NORMAL;
if (!_PyArg_ParseStack(args, nargs, "O|l:bkgd",
&ch, &attr)) {
if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) {
goto exit;
}
ch = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = PyLong_AsLong(args[1]);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_window_bkgd_impl(self, ch, attr);
exit:
@ -379,10 +392,23 @@ _curses_window_bkgdset(PyCursesWindowObject *self, PyObject *const *args, Py_ssi
PyObject *ch;
long attr = A_NORMAL;
if (!_PyArg_ParseStack(args, nargs, "O|l:bkgdset",
&ch, &attr)) {
if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) {
goto exit;
}
ch = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = PyLong_AsLong(args[1]);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_window_bkgdset_impl(self, ch, attr);
exit:
@ -623,10 +649,23 @@ _curses_window_echochar(PyCursesWindowObject *self, PyObject *const *args, Py_ss
PyObject *ch;
long attr = A_NORMAL;
if (!_PyArg_ParseStack(args, nargs, "O|l:echochar",
&ch, &attr)) {
if (!_PyArg_CheckPositional("echochar", nargs, 1, 2)) {
goto exit;
}
ch = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = PyLong_AsLong(args[1]);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_window_echochar_impl(self, ch, attr);
exit:
@ -660,8 +699,25 @@ _curses_window_enclose(PyCursesWindowObject *self, PyObject *const *args, Py_ssi
int x;
long _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:enclose",
&y, &x)) {
if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
y = _PyLong_AsInt(args[0]);
if (y == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
x = _PyLong_AsInt(args[1]);
if (x == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _curses_window_enclose_impl(self, y, x);
@ -1462,8 +1518,25 @@ _curses_window_redrawln(PyCursesWindowObject *self, PyObject *const *args, Py_ss
int beg;
int num;
if (!_PyArg_ParseStack(args, nargs, "ii:redrawln",
&beg, &num)) {
if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
beg = _PyLong_AsInt(args[0]);
if (beg == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
num = _PyLong_AsInt(args[1]);
if (num == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_redrawln_impl(self, beg, num);
@ -1554,8 +1627,25 @@ _curses_window_setscrreg(PyCursesWindowObject *self, PyObject *const *args, Py_s
int top;
int bottom;
if (!_PyArg_ParseStack(args, nargs, "ii:setscrreg",
&top, &bottom)) {
if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
top = _PyLong_AsInt(args[0]);
if (top == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
bottom = _PyLong_AsInt(args[1]);
if (bottom == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_setscrreg_impl(self, top, bottom);
@ -1878,10 +1968,22 @@ _curses_cbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:cbreak",
&flag)) {
if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(args[0]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_cbreak_impl(module, flag);
exit:
@ -2158,10 +2260,22 @@ _curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:echo",
&flag)) {
if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(args[0]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_echo_impl(module, flag);
exit:
@ -2321,10 +2435,65 @@ _curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int z;
unsigned long bstate;
if (!_PyArg_ParseStack(args, nargs, "hiiik:ungetmouse",
&id, &x, &y, &z, &bstate)) {
if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[0]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
id = (short) ival;
}
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
x = _PyLong_AsInt(args[1]);
if (x == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
y = _PyLong_AsInt(args[2]);
if (y == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
z = _PyLong_AsInt(args[3]);
if (z == -1 && PyErr_Occurred()) {
goto exit;
}
if (!PyLong_Check(args[4])) {
_PyArg_BadArgument("ungetmouse", 5, "int", args[4]);
goto exit;
}
bstate = PyLong_AsUnsignedLongMask(args[4]);
return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate);
exit:
@ -2527,10 +2696,105 @@ _curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
short g;
short b;
if (!_PyArg_ParseStack(args, nargs, "hhhh:init_color",
&color_number, &r, &g, &b)) {
if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[0]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
color_number = (short) ival;
}
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[1]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
r = (short) ival;
}
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[2]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
g = (short) ival;
}
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[3]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
b = (short) ival;
}
}
return_value = _curses_init_color_impl(module, color_number, r, g, b);
exit:
@ -2568,10 +2832,81 @@ _curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
short fg;
short bg;
if (!_PyArg_ParseStack(args, nargs, "hhh:init_pair",
&pair_number, &fg, &bg)) {
if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[0]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
pair_number = (short) ival;
}
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[1]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
fg = (short) ival;
}
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(args[2]);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < SHRT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is less than minimum");
goto exit;
}
else if (ival > SHRT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed short integer is greater than maximum");
goto exit;
}
else {
bg = (short) ival;
}
}
return_value = _curses_init_pair_impl(module, pair_number, fg, bg);
exit:
@ -2712,8 +3047,25 @@ _curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t narg
int nlines;
int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:is_term_resized",
&nlines, &ncols)) {
if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nlines = _PyLong_AsInt(args[0]);
if (nlines == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
ncols = _PyLong_AsInt(args[1]);
if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_is_term_resized_impl(module, nlines, ncols);
@ -2905,7 +3257,7 @@ _curses_mousemask(PyObject *module, PyObject *arg)
unsigned long newmask;
if (!PyLong_Check(arg)) {
_PyArg_BadArgument("mousemask", "int", arg);
_PyArg_BadArgument("mousemask", 0, "int", arg);
goto exit;
}
newmask = PyLong_AsUnsignedLongMask(arg);
@ -2977,8 +3329,25 @@ _curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines;
int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:newpad",
&nlines, &ncols)) {
if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nlines = _PyLong_AsInt(args[0]);
if (nlines == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
ncols = _PyLong_AsInt(args[1]);
if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_newpad_impl(module, nlines, ncols);
@ -3066,10 +3435,22 @@ _curses_nl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:nl",
&flag)) {
if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(args[0]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_nl_impl(module, flag);
exit:
@ -3317,10 +3698,22 @@ _curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:qiflush",
&flag)) {
if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(args[0]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_qiflush_impl(module, flag);
exit:
@ -3383,10 +3776,22 @@ _curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:raw",
&flag)) {
if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(args[0]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _curses_raw_impl(module, flag);
exit:
@ -3476,8 +3881,25 @@ _curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines;
int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:resizeterm",
&nlines, &ncols)) {
if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nlines = _PyLong_AsInt(args[0]);
if (nlines == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
ncols = _PyLong_AsInt(args[1]);
if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_resizeterm_impl(module, nlines, ncols);
@ -3520,8 +3942,25 @@ _curses_resize_term(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines;
int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:resize_term",
&nlines, &ncols)) {
if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nlines = _PyLong_AsInt(args[0]);
if (nlines == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
ncols = _PyLong_AsInt(args[1]);
if (ncols == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_resize_term_impl(module, nlines, ncols);
@ -3578,8 +4017,25 @@ _curses_setsyx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int y;
int x;
if (!_PyArg_ParseStack(args, nargs, "ii:setsyx",
&y, &x)) {
if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
y = _PyLong_AsInt(args[0]);
if (y == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
x = _PyLong_AsInt(args[1]);
if (x == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_setsyx_impl(module, y, x);
@ -3676,7 +4132,7 @@ _curses_tigetflag(PyObject *module, PyObject *arg)
const char *capname;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetflag", "str", arg);
_PyArg_BadArgument("tigetflag", 0, "str", arg);
goto exit;
}
Py_ssize_t capname_length;
@ -3719,7 +4175,7 @@ _curses_tigetnum(PyObject *module, PyObject *arg)
const char *capname;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetnum", "str", arg);
_PyArg_BadArgument("tigetnum", 0, "str", arg);
goto exit;
}
Py_ssize_t capname_length;
@ -3762,7 +4218,7 @@ _curses_tigetstr(PyObject *module, PyObject *arg)
const char *capname;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetstr", "str", arg);
_PyArg_BadArgument("tigetstr", 0, "str", arg);
goto exit;
}
Py_ssize_t capname_length;
@ -4044,4 +4500,4 @@ _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
/*[clinic end generated code: output=a2bbced3c5d29d64 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ceb2e32ee1370033 input=a9049054013a1b77]*/

View File

@ -132,13 +132,49 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *flags = "r";
int mode = 438;
if (!_PyArg_ParseStack(args, nargs, "U|si:open",
&filename, &flags, &mode)) {
if (!_PyArg_CheckPositional("open", nargs, 1, 3)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("open", 1, "str", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
filename = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("open", 2, "str", args[1]);
goto exit;
}
Py_ssize_t flags_length;
flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length);
if (flags == NULL) {
goto exit;
}
if (strlen(flags) != (size_t)flags_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[2]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = dbmopen_impl(module, filename, flags, mode);
exit:
return return_value;
}
/*[clinic end generated code: output=e4585e78f5821b5b input=a9049054013a1b77]*/
/*[clinic end generated code: output=7f5d30ef5d820b8a input=a9049054013a1b77]*/

View File

@ -20,7 +20,7 @@ _elementtree_Element_append(ElementObject *self, PyObject *arg)
PyObject *subelement;
if (!PyObject_TypeCheck(arg, &Element_Type)) {
_PyArg_BadArgument("append", (&Element_Type)->tp_name, arg);
_PyArg_BadArgument("append", 0, (&Element_Type)->tp_name, arg);
goto exit;
}
subelement = arg;
@ -82,7 +82,7 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg)
PyObject *memo;
if (!PyDict_Check(arg)) {
_PyArg_BadArgument("__deepcopy__", "dict", arg);
_PyArg_BadArgument("__deepcopy__", 0, "dict", arg);
goto exit;
}
memo = arg;
@ -420,10 +420,31 @@ _elementtree_Element_insert(ElementObject *self, PyObject *const *args, Py_ssize
Py_ssize_t index;
PyObject *subelement;
if (!_PyArg_ParseStack(args, nargs, "nO!:insert",
&index, &Element_Type, &subelement)) {
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
if (!PyObject_TypeCheck(args[1], &Element_Type)) {
_PyArg_BadArgument("insert", 2, (&Element_Type)->tp_name, args[1]);
goto exit;
}
subelement = args[1];
return_value = _elementtree_Element_insert_impl(self, index, subelement);
exit:
@ -512,7 +533,7 @@ _elementtree_Element_remove(ElementObject *self, PyObject *arg)
PyObject *subelement;
if (!PyObject_TypeCheck(arg, &Element_Type)) {
_PyArg_BadArgument("remove", (&Element_Type)->tp_name, arg);
_PyArg_BadArgument("remove", 0, (&Element_Type)->tp_name, arg);
goto exit;
}
subelement = arg;
@ -723,4 +744,4 @@ _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args,
exit:
return return_value;
}
/*[clinic end generated code: output=398640585689c5ed input=a9049054013a1b77]*/
/*[clinic end generated code: output=6bbedd24b709dc00 input=a9049054013a1b77]*/

View File

@ -245,13 +245,49 @@ dbmopen(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
const char *flags = "r";
int mode = 438;
if (!_PyArg_ParseStack(args, nargs, "U|si:open",
&filename, &flags, &mode)) {
if (!_PyArg_CheckPositional("open", nargs, 1, 3)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("open", 1, "str", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
filename = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("open", 2, "str", args[1]);
goto exit;
}
Py_ssize_t flags_length;
flags = PyUnicode_AsUTF8AndSize(args[1], &flags_length);
if (flags == NULL) {
goto exit;
}
if (strlen(flags) != (size_t)flags_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[2]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = dbmopen_impl(module, filename, flags, mode);
exit:
return return_value;
}
/*[clinic end generated code: output=5ca4361417bf96cb input=a9049054013a1b77]*/
/*[clinic end generated code: output=05f06065d2dc1f9e input=a9049054013a1b77]*/

View File

@ -29,7 +29,7 @@ _lzma_LZMACompressor_compress(Compressor *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg);
_PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _lzma_LZMACompressor_compress_impl(self, &data);
@ -252,8 +252,17 @@ _lzma__decode_filter_properties(PyObject *module, PyObject *const *args, Py_ssiz
lzma_vli filter_id;
Py_buffer encoded_props = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "O&y*:_decode_filter_properties",
lzma_vli_converter, &filter_id, &encoded_props)) {
if (!_PyArg_CheckPositional("_decode_filter_properties", nargs, 2, 2)) {
goto exit;
}
if (!lzma_vli_converter(args[0], &filter_id)) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &encoded_props, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&encoded_props, 'C')) {
_PyArg_BadArgument("_decode_filter_properties", 2, "contiguous buffer", args[1]);
goto exit;
}
return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props);
@ -266,4 +275,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=df061bfc2067a90a input=a9049054013a1b77]*/
/*[clinic end generated code: output=47e4732df79509ad input=a9049054013a1b77]*/

View File

@ -1416,10 +1416,31 @@ _operator_length_hint(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t default_value = 0;
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "O|n:length_hint",
&obj, &default_value)) {
if (!_PyArg_CheckPositional("length_hint", nargs, 1, 2)) {
goto exit;
}
obj = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
default_value = ival;
}
skip_optional:
_return_value = _operator_length_hint_impl(module, obj, default_value);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@ -1469,4 +1490,4 @@ _operator__compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t na
exit:
return return_value;
}
/*[clinic end generated code: output=424b884884ab20b7 input=a9049054013a1b77]*/
/*[clinic end generated code: output=b382bece80a5a254 input=a9049054013a1b77]*/

View File

@ -71,10 +71,17 @@ _ssl__SSLSocket_getpeercert(PySSLSocket *self, PyObject *const *args, Py_ssize_t
PyObject *return_value = NULL;
int binary_mode = 0;
if (!_PyArg_ParseStack(args, nargs, "|p:getpeercert",
&binary_mode)) {
if (!_PyArg_CheckPositional("getpeercert", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
binary_mode = PyObject_IsTrue(args[0]);
if (binary_mode < 0) {
goto exit;
}
skip_optional:
return_value = _ssl__SSLSocket_getpeercert_impl(self, binary_mode);
exit:
@ -215,7 +222,7 @@ _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
_PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLSocket_write_impl(self, &b);
@ -377,8 +384,16 @@ _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("_SSLContext", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "i:_SSLContext",
&proto_version)) {
if (!_PyArg_CheckPositional("_SSLContext", PyTuple_GET_SIZE(args), 1, 1)) {
goto exit;
}
if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
proto_version = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0));
if (proto_version == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _ssl__SSLContext_impl(type, proto_version);
@ -405,7 +420,7 @@ _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
const char *cipherlist;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("set_ciphers", "str", arg);
_PyArg_BadArgument("set_ciphers", 0, "str", arg);
goto exit;
}
Py_ssize_t cipherlist_length;
@ -466,7 +481,7 @@ _ssl__SSLContext__set_npn_protocols(PySSLContext *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_npn_protocols", "contiguous buffer", arg);
_PyArg_BadArgument("_set_npn_protocols", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos);
@ -502,7 +517,7 @@ _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_alpn_protocols", "contiguous buffer", arg);
_PyArg_BadArgument("_set_alpn_protocols", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
@ -815,10 +830,22 @@ _ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject *const *args, Py_ssize_t narg
PyObject *return_value = NULL;
int len = -1;
if (!_PyArg_ParseStack(args, nargs, "|i:read",
&len)) {
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
len = _PyLong_AsInt(args[0]);
if (len == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _ssl_MemoryBIO_read_impl(self, len);
exit:
@ -849,7 +876,7 @@ _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
_PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit;
}
return_value = _ssl_MemoryBIO_write_impl(self, &b);
@ -905,8 +932,28 @@ _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer view = {NULL, NULL};
double entropy;
if (!_PyArg_ParseStack(args, nargs, "s*d:RAND_add",
&view, &entropy)) {
if (!_PyArg_CheckPositional("RAND_add", nargs, 2, 2)) {
goto exit;
}
if (PyUnicode_Check(args[0])) {
Py_ssize_t len;
const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
if (ptr == NULL) {
goto exit;
}
PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0);
}
else { /* any bytes-like object */
if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&view, 'C')) {
_PyArg_BadArgument("RAND_add", 1, "contiguous buffer", args[0]);
goto exit;
}
}
entropy = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = _ssl_RAND_add_impl(module, &view, entropy);
@ -1237,4 +1284,4 @@ exit:
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
/*[clinic end generated code: output=c2dca2ef4cbef4e2 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ac3fb15ca27500f2 input=a9049054013a1b77]*/

View File

@ -61,7 +61,7 @@ Struct_unpack(PyStructObject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack", "contiguous buffer", arg);
_PyArg_BadArgument("unpack", 0, "contiguous buffer", arg);
goto exit;
}
return_value = Struct_unpack_impl(self, &buffer);
@ -209,8 +209,17 @@ unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyStructObject *s_object = NULL;
Py_buffer buffer = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "O&y*:unpack",
cache_struct_converter, &s_object, &buffer)) {
if (!_PyArg_CheckPositional("unpack", nargs, 2, 2)) {
goto exit;
}
if (!cache_struct_converter(args[0], &s_object)) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack", 2, "contiguous buffer", args[1]);
goto exit;
}
return_value = unpack_impl(module, s_object, &buffer);
@ -295,10 +304,13 @@ iter_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyStructObject *s_object = NULL;
PyObject *buffer;
if (!_PyArg_ParseStack(args, nargs, "O&O:iter_unpack",
cache_struct_converter, &s_object, &buffer)) {
if (!_PyArg_CheckPositional("iter_unpack", nargs, 2, 2)) {
goto exit;
}
if (!cache_struct_converter(args[0], &s_object)) {
goto exit;
}
buffer = args[1];
return_value = iter_unpack_impl(module, s_object, buffer);
exit:
@ -307,4 +319,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=01516bea2641fe01 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ac595db9d2b271aa input=a9049054013a1b77]*/

View File

@ -20,7 +20,7 @@ _tkinter_tkapp_eval(TkappObject *self, PyObject *arg)
const char *script;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("eval", "str", arg);
_PyArg_BadArgument("eval", 0, "str", arg);
goto exit;
}
Py_ssize_t script_length;
@ -56,7 +56,7 @@ _tkinter_tkapp_evalfile(TkappObject *self, PyObject *arg)
const char *fileName;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("evalfile", "str", arg);
_PyArg_BadArgument("evalfile", 0, "str", arg);
goto exit;
}
Py_ssize_t fileName_length;
@ -92,7 +92,7 @@ _tkinter_tkapp_record(TkappObject *self, PyObject *arg)
const char *script;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("record", "str", arg);
_PyArg_BadArgument("record", 0, "str", arg);
goto exit;
}
Py_ssize_t script_length;
@ -128,7 +128,7 @@ _tkinter_tkapp_adderrorinfo(TkappObject *self, PyObject *arg)
const char *msg;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("adderrorinfo", "str", arg);
_PyArg_BadArgument("adderrorinfo", 0, "str", arg);
goto exit;
}
Py_ssize_t msg_length;
@ -188,7 +188,7 @@ _tkinter_tkapp_exprstring(TkappObject *self, PyObject *arg)
const char *s;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprstring", "str", arg);
_PyArg_BadArgument("exprstring", 0, "str", arg);
goto exit;
}
Py_ssize_t s_length;
@ -224,7 +224,7 @@ _tkinter_tkapp_exprlong(TkappObject *self, PyObject *arg)
const char *s;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprlong", "str", arg);
_PyArg_BadArgument("exprlong", 0, "str", arg);
goto exit;
}
Py_ssize_t s_length;
@ -260,7 +260,7 @@ _tkinter_tkapp_exprdouble(TkappObject *self, PyObject *arg)
const char *s;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprdouble", "str", arg);
_PyArg_BadArgument("exprdouble", 0, "str", arg);
goto exit;
}
Py_ssize_t s_length;
@ -296,7 +296,7 @@ _tkinter_tkapp_exprboolean(TkappObject *self, PyObject *arg)
const char *s;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprboolean", "str", arg);
_PyArg_BadArgument("exprboolean", 0, "str", arg);
goto exit;
}
Py_ssize_t s_length;
@ -349,10 +349,23 @@ _tkinter_tkapp_createcommand(TkappObject *self, PyObject *const *args, Py_ssize_
const char *name;
PyObject *func;
if (!_PyArg_ParseStack(args, nargs, "sO:createcommand",
&name, &func)) {
if (!_PyArg_CheckPositional("createcommand", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("createcommand", 1, "str", args[0]);
goto exit;
}
Py_ssize_t name_length;
name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
func = args[1];
return_value = _tkinter_tkapp_createcommand_impl(self, name, func);
exit:
@ -377,7 +390,7 @@ _tkinter_tkapp_deletecommand(TkappObject *self, PyObject *arg)
const char *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("deletecommand", "str", arg);
_PyArg_BadArgument("deletecommand", 0, "str", arg);
goto exit;
}
Py_ssize_t name_length;
@ -417,10 +430,20 @@ _tkinter_tkapp_createfilehandler(TkappObject *self, PyObject *const *args, Py_ss
int mask;
PyObject *func;
if (!_PyArg_ParseStack(args, nargs, "OiO:createfilehandler",
&file, &mask, &func)) {
if (!_PyArg_CheckPositional("createfilehandler", nargs, 3, 3)) {
goto exit;
}
file = args[0];
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mask = _PyLong_AsInt(args[1]);
if (mask == -1 && PyErr_Occurred()) {
goto exit;
}
func = args[2];
return_value = _tkinter_tkapp_createfilehandler_impl(self, file, mask, func);
exit:
@ -477,10 +500,19 @@ _tkinter_tkapp_createtimerhandler(TkappObject *self, PyObject *const *args, Py_s
int milliseconds;
PyObject *func;
if (!_PyArg_ParseStack(args, nargs, "iO:createtimerhandler",
&milliseconds, &func)) {
if (!_PyArg_CheckPositional("createtimerhandler", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
milliseconds = _PyLong_AsInt(args[0]);
if (milliseconds == -1 && PyErr_Occurred()) {
goto exit;
}
func = args[1];
return_value = _tkinter_tkapp_createtimerhandler_impl(self, milliseconds, func);
exit:
@ -504,10 +536,22 @@ _tkinter_tkapp_mainloop(TkappObject *self, PyObject *const *args, Py_ssize_t nar
PyObject *return_value = NULL;
int threshold = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:mainloop",
&threshold)) {
if (!_PyArg_CheckPositional("mainloop", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
threshold = _PyLong_AsInt(args[0]);
if (threshold == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _tkinter_tkapp_mainloop_impl(self, threshold);
exit:
@ -531,10 +575,22 @@ _tkinter_tkapp_dooneevent(TkappObject *self, PyObject *const *args, Py_ssize_t n
PyObject *return_value = NULL;
int flags = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:dooneevent",
&flags)) {
if (!_PyArg_CheckPositional("dooneevent", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flags = _PyLong_AsInt(args[0]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _tkinter_tkapp_dooneevent_impl(self, flags);
exit:
@ -654,10 +710,132 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int sync = 0;
const char *use = NULL;
if (!_PyArg_ParseStack(args, nargs, "|zssiiiiz:create",
&screenName, &baseName, &className, &interactive, &wantobjects, &wantTk, &sync, &use)) {
if (!_PyArg_CheckPositional("create", nargs, 0, 8)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (args[0] == Py_None) {
screenName = NULL;
}
else if (PyUnicode_Check(args[0])) {
Py_ssize_t screenName_length;
screenName = PyUnicode_AsUTF8AndSize(args[0], &screenName_length);
if (screenName == NULL) {
goto exit;
}
if (strlen(screenName) != (size_t)screenName_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
_PyArg_BadArgument("create", 1, "str or None", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("create", 2, "str", args[1]);
goto exit;
}
Py_ssize_t baseName_length;
baseName = PyUnicode_AsUTF8AndSize(args[1], &baseName_length);
if (baseName == NULL) {
goto exit;
}
if (strlen(baseName) != (size_t)baseName_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (!PyUnicode_Check(args[2])) {
_PyArg_BadArgument("create", 3, "str", args[2]);
goto exit;
}
Py_ssize_t className_length;
className = PyUnicode_AsUTF8AndSize(args[2], &className_length);
if (className == NULL) {
goto exit;
}
if (strlen(className) != (size_t)className_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (nargs < 4) {
goto skip_optional;
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
interactive = _PyLong_AsInt(args[3]);
if (interactive == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 5) {
goto skip_optional;
}
if (PyFloat_Check(args[4])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
wantobjects = _PyLong_AsInt(args[4]);
if (wantobjects == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 6) {
goto skip_optional;
}
if (PyFloat_Check(args[5])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
wantTk = _PyLong_AsInt(args[5]);
if (wantTk == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 7) {
goto skip_optional;
}
if (PyFloat_Check(args[6])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
sync = _PyLong_AsInt(args[6]);
if (sync == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 8) {
goto skip_optional;
}
if (args[7] == Py_None) {
use = NULL;
}
else if (PyUnicode_Check(args[7])) {
Py_ssize_t use_length;
use = PyUnicode_AsUTF8AndSize(args[7], &use_length);
if (use == NULL) {
goto exit;
}
if (strlen(use) != (size_t)use_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
_PyArg_BadArgument("create", 8, "str or None", args[7]);
goto exit;
}
skip_optional:
return_value = _tkinter_create_impl(module, screenName, baseName, className, interactive, wantobjects, wantTk, sync, use);
exit:
@ -734,4 +912,4 @@ exit:
#ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */
/*[clinic end generated code: output=d84b0e794824c511 input=a9049054013a1b77]*/
/*[clinic end generated code: output=2cf95f0101f3dbca input=a9049054013a1b77]*/

View File

@ -95,10 +95,22 @@ _tracemalloc_start(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int nframe = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:start",
&nframe)) {
if (!_PyArg_CheckPositional("start", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nframe = _PyLong_AsInt(args[0]);
if (nframe == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = _tracemalloc_start_impl(module, nframe);
exit:
@ -185,4 +197,4 @@ _tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _tracemalloc_get_traced_memory_impl(module);
}
/*[clinic end generated code: output=d4a2dd3eaba9f72d input=a9049054013a1b77]*/
/*[clinic end generated code: output=1bc96dc569706afa input=a9049054013a1b77]*/

View File

@ -50,13 +50,18 @@ _weakref__remove_dead_weakref(PyObject *module, PyObject *const *args, Py_ssize_
PyObject *dct;
PyObject *key;
if (!_PyArg_ParseStack(args, nargs, "O!O:_remove_dead_weakref",
&PyDict_Type, &dct, &key)) {
if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) {
goto exit;
}
if (!PyDict_Check(args[0])) {
_PyArg_BadArgument("_remove_dead_weakref", 1, "dict", args[0]);
goto exit;
}
dct = args[0];
key = args[1];
return_value = _weakref__remove_dead_weakref_impl(module, dct, key);
exit:
return return_value;
}
/*[clinic end generated code: output=927e889feb8a7dc4 input=a9049054013a1b77]*/
/*[clinic end generated code: output=eae22e2d2e43120e input=a9049054013a1b77]*/

View File

@ -76,10 +76,30 @@ array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t i = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:pop",
&i)) {
if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
i = ival;
}
skip_optional:
return_value = array_array_pop_impl(self, i);
exit:
@ -114,10 +134,27 @@ array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t i;
PyObject *v;
if (!_PyArg_ParseStack(args, nargs, "nO:insert",
&i, &v)) {
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
i = ival;
}
v = args[1];
return_value = array_array_insert_impl(self, i, v);
exit:
@ -212,10 +249,27 @@ array_array_fromfile(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *f;
Py_ssize_t n;
if (!_PyArg_ParseStack(args, nargs, "On:fromfile",
&f, &n)) {
if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) {
goto exit;
}
f = args[0];
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
n = ival;
}
return_value = array_array_fromfile_impl(self, f, n);
exit:
@ -291,7 +345,7 @@ array_array_fromstring(arrayobject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("fromstring", "contiguous buffer", arg);
_PyArg_BadArgument("fromstring", 0, "contiguous buffer", arg);
goto exit;
}
}
@ -328,7 +382,7 @@ array_array_frombytes(arrayobject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("frombytes", "contiguous buffer", arg);
_PyArg_BadArgument("frombytes", 0, "contiguous buffer", arg);
goto exit;
}
return_value = array_array_frombytes_impl(self, &buffer);
@ -478,10 +532,32 @@ array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t n
enum machine_format_code mformat_code;
PyObject *items;
if (!_PyArg_ParseStack(args, nargs, "OCiO:_array_reconstructor",
&arraytype, &typecode, &mformat_code, &items)) {
if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) {
goto exit;
}
arraytype = (PyTypeObject *)args[0];
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("_array_reconstructor", 2, "a unicode character", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1])) {
goto exit;
}
if (PyUnicode_GET_LENGTH(args[1]) != 1) {
_PyArg_BadArgument("_array_reconstructor", 2, "a unicode character", args[1]);
goto exit;
}
typecode = PyUnicode_READ_CHAR(args[1], 0);
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mformat_code = _PyLong_AsInt(args[2]);
if (mformat_code == -1 && PyErr_Occurred()) {
goto exit;
}
items = args[3];
return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
exit:
@ -523,4 +599,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
/*[clinic end generated code: output=15da19d2ece09d22 input=a9049054013a1b77]*/
/*[clinic end generated code: output=c9a40f11f1a866fb input=a9049054013a1b77]*/

View File

@ -23,10 +23,42 @@ audioop_getsample(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width;
Py_ssize_t index;
if (!_PyArg_ParseStack(args, nargs, "y*in:getsample",
&fragment, &width, &index)) {
if (!_PyArg_CheckPositional("getsample", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("getsample", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
return_value = audioop_getsample_impl(module, &fragment, width, index);
exit:
@ -57,8 +89,23 @@ audioop_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:max",
&fragment, &width)) {
if (!_PyArg_CheckPositional("max", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("max", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_max_impl(module, &fragment, width);
@ -91,8 +138,23 @@ audioop_minmax(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:minmax",
&fragment, &width)) {
if (!_PyArg_CheckPositional("minmax", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("minmax", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_minmax_impl(module, &fragment, width);
@ -125,8 +187,23 @@ audioop_avg(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:avg",
&fragment, &width)) {
if (!_PyArg_CheckPositional("avg", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("avg", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_avg_impl(module, &fragment, width);
@ -159,8 +236,23 @@ audioop_rms(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:rms",
&fragment, &width)) {
if (!_PyArg_CheckPositional("rms", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("rms", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_rms_impl(module, &fragment, width);
@ -194,8 +286,21 @@ audioop_findfit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
Py_buffer reference = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:findfit",
&fragment, &reference)) {
if (!_PyArg_CheckPositional("findfit", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("findfit", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&reference, 'C')) {
_PyArg_BadArgument("findfit", 2, "contiguous buffer", args[1]);
goto exit;
}
return_value = audioop_findfit_impl(module, &fragment, &reference);
@ -233,8 +338,21 @@ audioop_findfactor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
Py_buffer reference = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:findfactor",
&fragment, &reference)) {
if (!_PyArg_CheckPositional("findfactor", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("findfactor", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &reference, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&reference, 'C')) {
_PyArg_BadArgument("findfactor", 2, "contiguous buffer", args[1]);
goto exit;
}
return_value = audioop_findfactor_impl(module, &fragment, &reference);
@ -272,10 +390,33 @@ audioop_findmax(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
Py_ssize_t length;
if (!_PyArg_ParseStack(args, nargs, "y*n:findmax",
&fragment, &length)) {
if (!_PyArg_CheckPositional("findmax", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("findmax", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
length = ival;
}
return_value = audioop_findmax_impl(module, &fragment, length);
exit:
@ -306,8 +447,23 @@ audioop_avgpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:avgpp",
&fragment, &width)) {
if (!_PyArg_CheckPositional("avgpp", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("avgpp", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_avgpp_impl(module, &fragment, width);
@ -340,8 +496,23 @@ audioop_maxpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:maxpp",
&fragment, &width)) {
if (!_PyArg_CheckPositional("maxpp", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("maxpp", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_maxpp_impl(module, &fragment, width);
@ -374,8 +545,23 @@ audioop_cross(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:cross",
&fragment, &width)) {
if (!_PyArg_CheckPositional("cross", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("cross", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_cross_impl(module, &fragment, width);
@ -410,8 +596,27 @@ audioop_mul(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width;
double factor;
if (!_PyArg_ParseStack(args, nargs, "y*id:mul",
&fragment, &width, &factor)) {
if (!_PyArg_CheckPositional("mul", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("mul", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
factor = PyFloat_AsDouble(args[2]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = audioop_mul_impl(module, &fragment, width, factor);
@ -447,8 +652,31 @@ audioop_tomono(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double lfactor;
double rfactor;
if (!_PyArg_ParseStack(args, nargs, "y*idd:tomono",
&fragment, &width, &lfactor, &rfactor)) {
if (!_PyArg_CheckPositional("tomono", nargs, 4, 4)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("tomono", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
lfactor = PyFloat_AsDouble(args[2]);
if (PyErr_Occurred()) {
goto exit;
}
rfactor = PyFloat_AsDouble(args[3]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor);
@ -484,8 +712,31 @@ audioop_tostereo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double lfactor;
double rfactor;
if (!_PyArg_ParseStack(args, nargs, "y*idd:tostereo",
&fragment, &width, &lfactor, &rfactor)) {
if (!_PyArg_CheckPositional("tostereo", nargs, 4, 4)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("tostereo", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
lfactor = PyFloat_AsDouble(args[2]);
if (PyErr_Occurred()) {
goto exit;
}
rfactor = PyFloat_AsDouble(args[3]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor);
@ -520,8 +771,30 @@ audioop_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment2 = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*y*i:add",
&fragment1, &fragment2, &width)) {
if (!_PyArg_CheckPositional("add", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment1, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment1, 'C')) {
_PyArg_BadArgument("add", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &fragment2, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment2, 'C')) {
_PyArg_BadArgument("add", 2, "contiguous buffer", args[1]);
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[2]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_add_impl(module, &fragment1, &fragment2, width);
@ -559,8 +832,32 @@ audioop_bias(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width;
int bias;
if (!_PyArg_ParseStack(args, nargs, "y*ii:bias",
&fragment, &width, &bias)) {
if (!_PyArg_CheckPositional("bias", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("bias", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
bias = _PyLong_AsInt(args[2]);
if (bias == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_bias_impl(module, &fragment, width, bias);
@ -593,8 +890,23 @@ audioop_reverse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:reverse",
&fragment, &width)) {
if (!_PyArg_CheckPositional("reverse", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("reverse", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_reverse_impl(module, &fragment, width);
@ -627,8 +939,23 @@ audioop_byteswap(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:byteswap",
&fragment, &width)) {
if (!_PyArg_CheckPositional("byteswap", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("byteswap", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_byteswap_impl(module, &fragment, width);
@ -663,8 +990,32 @@ audioop_lin2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width;
int newwidth;
if (!_PyArg_ParseStack(args, nargs, "y*ii:lin2lin",
&fragment, &width, &newwidth)) {
if (!_PyArg_CheckPositional("lin2lin", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("lin2lin", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
newwidth = _PyLong_AsInt(args[2]);
if (newwidth == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth);
@ -706,10 +1057,78 @@ audioop_ratecv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int weightA = 1;
int weightB = 0;
if (!_PyArg_ParseStack(args, nargs, "y*iiiiO|ii:ratecv",
&fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB)) {
if (!_PyArg_CheckPositional("ratecv", nargs, 6, 8)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("ratecv", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nchannels = _PyLong_AsInt(args[2]);
if (nchannels == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
inrate = _PyLong_AsInt(args[3]);
if (inrate == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[4])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
outrate = _PyLong_AsInt(args[4]);
if (outrate == -1 && PyErr_Occurred()) {
goto exit;
}
state = args[5];
if (nargs < 7) {
goto skip_optional;
}
if (PyFloat_Check(args[6])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
weightA = _PyLong_AsInt(args[6]);
if (weightA == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 8) {
goto skip_optional;
}
if (PyFloat_Check(args[7])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
weightB = _PyLong_AsInt(args[7]);
if (weightB == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB);
exit:
@ -740,8 +1159,23 @@ audioop_lin2ulaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:lin2ulaw",
&fragment, &width)) {
if (!_PyArg_CheckPositional("lin2ulaw", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("lin2ulaw", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_lin2ulaw_impl(module, &fragment, width);
@ -774,8 +1208,23 @@ audioop_ulaw2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:ulaw2lin",
&fragment, &width)) {
if (!_PyArg_CheckPositional("ulaw2lin", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("ulaw2lin", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_ulaw2lin_impl(module, &fragment, width);
@ -808,8 +1257,23 @@ audioop_lin2alaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:lin2alaw",
&fragment, &width)) {
if (!_PyArg_CheckPositional("lin2alaw", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("lin2alaw", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_lin2alaw_impl(module, &fragment, width);
@ -842,8 +1306,23 @@ audioop_alaw2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL};
int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:alaw2lin",
&fragment, &width)) {
if (!_PyArg_CheckPositional("alaw2lin", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("alaw2lin", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = audioop_alaw2lin_impl(module, &fragment, width);
@ -878,10 +1357,26 @@ audioop_lin2adpcm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width;
PyObject *state;
if (!_PyArg_ParseStack(args, nargs, "y*iO:lin2adpcm",
&fragment, &width, &state)) {
if (!_PyArg_CheckPositional("lin2adpcm", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("lin2adpcm", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
state = args[2];
return_value = audioop_lin2adpcm_impl(module, &fragment, width, state);
exit:
@ -914,10 +1409,26 @@ audioop_adpcm2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width;
PyObject *state;
if (!_PyArg_ParseStack(args, nargs, "y*iO:adpcm2lin",
&fragment, &width, &state)) {
if (!_PyArg_CheckPositional("adpcm2lin", nargs, 3, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &fragment, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&fragment, 'C')) {
_PyArg_BadArgument("adpcm2lin", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
width = _PyLong_AsInt(args[1]);
if (width == -1 && PyErr_Occurred()) {
goto exit;
}
state = args[2];
return_value = audioop_adpcm2lin_impl(module, &fragment, width, state);
exit:
@ -928,4 +1439,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=d197b1559196a48a input=a9049054013a1b77]*/
/*[clinic end generated code: output=2b173a25726252e9 input=a9049054013a1b77]*/

View File

@ -189,7 +189,7 @@ binascii_rlecode_hqx(PyObject *module, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("rlecode_hqx", "contiguous buffer", arg);
_PyArg_BadArgument("rlecode_hqx", 0, "contiguous buffer", arg);
goto exit;
}
return_value = binascii_rlecode_hqx_impl(module, &data);
@ -225,7 +225,7 @@ binascii_b2a_hqx(PyObject *module, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hqx", "contiguous buffer", arg);
_PyArg_BadArgument("b2a_hqx", 0, "contiguous buffer", arg);
goto exit;
}
return_value = binascii_b2a_hqx_impl(module, &data);
@ -261,7 +261,7 @@ binascii_rledecode_hqx(PyObject *module, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("rledecode_hqx", "contiguous buffer", arg);
_PyArg_BadArgument("rledecode_hqx", 0, "contiguous buffer", arg);
goto exit;
}
return_value = binascii_rledecode_hqx_impl(module, &data);
@ -295,8 +295,23 @@ binascii_crc_hqx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
unsigned int crc;
unsigned int _return_value;
if (!_PyArg_ParseStack(args, nargs, "y*I:crc_hqx",
&data, &crc)) {
if (!_PyArg_CheckPositional("crc_hqx", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("crc_hqx", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
if (crc == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
_return_value = binascii_crc_hqx_impl(module, &data, crc);
@ -334,10 +349,29 @@ binascii_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
unsigned int crc = 0;
unsigned int _return_value;
if (!_PyArg_ParseStack(args, nargs, "y*|I:crc32",
&data, &crc)) {
if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("crc32", 1, "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
if (crc == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
_return_value = binascii_crc32_impl(module, &data, crc);
if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
goto exit;
@ -378,7 +412,7 @@ binascii_b2a_hex(PyObject *module, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hex", "contiguous buffer", arg);
_PyArg_BadArgument("b2a_hex", 0, "contiguous buffer", arg);
goto exit;
}
return_value = binascii_b2a_hex_impl(module, &data);
@ -416,7 +450,7 @@ binascii_hexlify(PyObject *module, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("hexlify", "contiguous buffer", arg);
_PyArg_BadArgument("hexlify", 0, "contiguous buffer", arg);
goto exit;
}
return_value = binascii_hexlify_impl(module, &data);
@ -574,4 +608,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=8ff0cb5717b15d1b input=a9049054013a1b77]*/
/*[clinic end generated code: output=7210a01a718da4a0 input=a9049054013a1b77]*/

View File

@ -668,10 +668,18 @@ cmath_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_complex x;
PyObject *y_obj = NULL;
if (!_PyArg_ParseStack(args, nargs, "D|O:log",
&x, &y_obj)) {
if (!_PyArg_CheckPositional("log", nargs, 1, 2)) {
goto exit;
}
x = PyComplex_AsCComplex(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
y_obj = args[1];
skip_optional:
return_value = cmath_log_impl(module, x, y_obj);
exit:
@ -755,8 +763,15 @@ cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double r;
double phi;
if (!_PyArg_ParseStack(args, nargs, "dd:rect",
&r, &phi)) {
if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) {
goto exit;
}
r = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
phi = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = cmath_rect_impl(module, r, phi);
@ -902,4 +917,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
exit:
return return_value;
}
/*[clinic end generated code: output=50a105aa2bc5308f input=a9049054013a1b77]*/
/*[clinic end generated code: output=86a365d23f34aaff input=a9049054013a1b77]*/

View File

@ -32,10 +32,26 @@ fcntl_fcntl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int code;
PyObject *arg = NULL;
if (!_PyArg_ParseStack(args, nargs, "O&i|O:fcntl",
conv_descriptor, &fd, &code, &arg)) {
if (!_PyArg_CheckPositional("fcntl", nargs, 2, 3)) {
goto exit;
}
if (!conv_descriptor(args[0], &fd)) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
code = _PyLong_AsInt(args[1]);
if (code == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
arg = args[2];
skip_optional:
return_value = fcntl_fcntl_impl(module, fd, code, arg);
exit:
@ -91,10 +107,33 @@ fcntl_ioctl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *ob_arg = NULL;
int mutate_arg = 1;
if (!_PyArg_ParseStack(args, nargs, "O&I|Op:ioctl",
conv_descriptor, &fd, &code, &ob_arg, &mutate_arg)) {
if (!_PyArg_CheckPositional("ioctl", nargs, 2, 4)) {
goto exit;
}
if (!conv_descriptor(args[0], &fd)) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
code = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
if (code == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
ob_arg = args[2];
if (nargs < 4) {
goto skip_optional;
}
mutate_arg = PyObject_IsTrue(args[3]);
if (mutate_arg < 0) {
goto exit;
}
skip_optional:
return_value = fcntl_ioctl_impl(module, fd, code, ob_arg, mutate_arg);
exit:
@ -123,8 +162,19 @@ fcntl_flock(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd;
int code;
if (!_PyArg_ParseStack(args, nargs, "O&i:flock",
conv_descriptor, &fd, &code)) {
if (!_PyArg_CheckPositional("flock", nargs, 2, 2)) {
goto exit;
}
if (!conv_descriptor(args[0], &fd)) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
code = _PyLong_AsInt(args[1]);
if (code == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = fcntl_flock_impl(module, fd, code);
@ -177,13 +227,45 @@ fcntl_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *startobj = NULL;
int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O&i|OOi:lockf",
conv_descriptor, &fd, &code, &lenobj, &startobj, &whence)) {
if (!_PyArg_CheckPositional("lockf", nargs, 2, 5)) {
goto exit;
}
if (!conv_descriptor(args[0], &fd)) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
code = _PyLong_AsInt(args[1]);
if (code == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
lenobj = args[2];
if (nargs < 4) {
goto skip_optional;
}
startobj = args[3];
if (nargs < 5) {
goto skip_optional;
}
if (PyFloat_Check(args[4])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
whence = _PyLong_AsInt(args[4]);
if (whence == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = fcntl_lockf_impl(module, fd, code, lenobj, startobj, whence);
exit:
return return_value;
}
/*[clinic end generated code: output=fc1a781750750a14 input=a9049054013a1b77]*/
/*[clinic end generated code: output=e912d25e28362c52 input=a9049054013a1b77]*/

View File

@ -52,10 +52,15 @@ itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("_grouper", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "O!O:_grouper",
&groupby_type, &parent, &tgtkey)) {
if (!_PyArg_CheckPositional("_grouper", PyTuple_GET_SIZE(args), 2, 2)) {
goto exit;
}
if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), &groupby_type)) {
_PyArg_BadArgument("_grouper", 1, (&groupby_type)->tp_name, PyTuple_GET_ITEM(args, 0));
goto exit;
}
parent = PyTuple_GET_ITEM(args, 0);
tgtkey = PyTuple_GET_ITEM(args, 1);
return_value = itertools__grouper_impl(type, parent, tgtkey);
exit:
@ -84,10 +89,16 @@ itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("teedataobject", kwargs)) {
goto exit;
}
if (!PyArg_ParseTuple(args, "OO!O:teedataobject",
&it, &PyList_Type, &values, &next)) {
if (!_PyArg_CheckPositional("teedataobject", PyTuple_GET_SIZE(args), 3, 3)) {
goto exit;
}
it = PyTuple_GET_ITEM(args, 0);
if (!PyList_Check(PyTuple_GET_ITEM(args, 1))) {
_PyArg_BadArgument("teedataobject", 2, "list", PyTuple_GET_ITEM(args, 1));
goto exit;
}
values = PyTuple_GET_ITEM(args, 1);
next = PyTuple_GET_ITEM(args, 2);
return_value = itertools_teedataobject_impl(type, it, values, next);
exit:
@ -143,10 +154,31 @@ itertools_tee(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *iterable;
Py_ssize_t n = 2;
if (!_PyArg_ParseStack(args, nargs, "O|n:tee",
&iterable, &n)) {
if (!_PyArg_CheckPositional("tee", nargs, 1, 2)) {
goto exit;
}
iterable = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
n = ival;
}
skip_optional:
return_value = itertools_tee_impl(module, iterable, n);
exit:
@ -510,4 +542,4 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=916251f891fa84b9 input=a9049054013a1b77]*/
/*[clinic end generated code: output=f289354f54e04c13 input=a9049054013a1b77]*/

View File

@ -139,10 +139,14 @@ math_ldexp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double x;
PyObject *i;
if (!_PyArg_ParseStack(args, nargs, "dO:ldexp",
&x, &i)) {
if (!_PyArg_CheckPositional("ldexp", nargs, 2, 2)) {
goto exit;
}
x = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
i = args[1];
return_value = math_ldexp_impl(module, x, i);
exit:
@ -261,8 +265,15 @@ math_fmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double x;
double y;
if (!_PyArg_ParseStack(args, nargs, "dd:fmod",
&x, &y)) {
if (!_PyArg_CheckPositional("fmod", nargs, 2, 2)) {
goto exit;
}
x = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
y = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_fmod_impl(module, x, y);
@ -326,8 +337,15 @@ math_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double x;
double y;
if (!_PyArg_ParseStack(args, nargs, "dd:pow",
&x, &y)) {
if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) {
goto exit;
}
x = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
y = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_pow_impl(module, x, y);
@ -530,4 +548,4 @@ math_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
exit:
return return_value;
}
/*[clinic end generated code: output=da4b9940a5cb0188 input=a9049054013a1b77]*/
/*[clinic end generated code: output=2fe4fecd85585313 input=a9049054013a1b77]*/

View File

@ -1658,10 +1658,13 @@ os_execv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
path_t path = PATH_T_INITIALIZE("execv", "path", 0, 0);
PyObject *argv;
if (!_PyArg_ParseStack(args, nargs, "O&O:execv",
path_converter, &path, &argv)) {
if (!_PyArg_CheckPositional("execv", nargs, 2, 2)) {
goto exit;
}
if (!path_converter(args[0], &path)) {
goto exit;
}
argv = args[1];
return_value = os_execv_impl(module, &path, argv);
exit:
@ -1817,10 +1820,22 @@ os_spawnv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
path_t path = PATH_T_INITIALIZE("spawnv", "path", 0, 0);
PyObject *argv;
if (!_PyArg_ParseStack(args, nargs, "iO&O:spawnv",
&mode, path_converter, &path, &argv)) {
if (!_PyArg_CheckPositional("spawnv", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[0]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
if (!path_converter(args[1], &path)) {
goto exit;
}
argv = args[2];
return_value = os_spawnv_impl(module, mode, &path, argv);
exit:
@ -1865,10 +1880,23 @@ os_spawnve(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *argv;
PyObject *env;
if (!_PyArg_ParseStack(args, nargs, "iO&OO:spawnve",
&mode, path_converter, &path, &argv, &env)) {
if (!_PyArg_CheckPositional("spawnve", nargs, 4, 4)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[0]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
if (!path_converter(args[1], &path)) {
goto exit;
}
argv = args[2];
env = args[3];
return_value = os_spawnve_impl(module, mode, &path, argv, env);
exit:
@ -2874,8 +2902,13 @@ os_setreuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
uid_t ruid;
uid_t euid;
if (!_PyArg_ParseStack(args, nargs, "O&O&:setreuid",
_Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) {
if (!_PyArg_CheckPositional("setreuid", nargs, 2, 2)) {
goto exit;
}
if (!_Py_Uid_Converter(args[0], &ruid)) {
goto exit;
}
if (!_Py_Uid_Converter(args[1], &euid)) {
goto exit;
}
return_value = os_setreuid_impl(module, ruid, euid);
@ -2907,8 +2940,13 @@ os_setregid(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
gid_t rgid;
gid_t egid;
if (!_PyArg_ParseStack(args, nargs, "O&O&:setregid",
_Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) {
if (!_PyArg_CheckPositional("setregid", nargs, 2, 2)) {
goto exit;
}
if (!_Py_Gid_Converter(args[0], &rgid)) {
goto exit;
}
if (!_Py_Gid_Converter(args[1], &egid)) {
goto exit;
}
return_value = os_setregid_impl(module, rgid, egid);
@ -3558,8 +3596,25 @@ os_closerange(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd_low;
int fd_high;
if (!_PyArg_ParseStack(args, nargs, "ii:closerange",
&fd_low, &fd_high)) {
if (!_PyArg_CheckPositional("closerange", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd_low = _PyLong_AsInt(args[0]);
if (fd_low == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd_high = _PyLong_AsInt(args[1]);
if (fd_high == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_closerange_impl(module, fd_low, fd_high);
@ -3672,8 +3727,28 @@ os_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int command;
Py_off_t length;
if (!_PyArg_ParseStack(args, nargs, "iiO&:lockf",
&fd, &command, Py_off_t_converter, &length)) {
if (!_PyArg_CheckPositional("lockf", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
command = _PyLong_AsInt(args[1]);
if (command == -1 && PyErr_Occurred()) {
goto exit;
}
if (!Py_off_t_converter(args[2], &length)) {
goto exit;
}
return_value = os_lockf_impl(module, fd, command, length);
@ -3708,8 +3783,28 @@ os_lseek(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int how;
Py_off_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO&i:lseek",
&fd, Py_off_t_converter, &position, &how)) {
if (!_PyArg_CheckPositional("lseek", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (!Py_off_t_converter(args[1], &position)) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
how = _PyLong_AsInt(args[2]);
if (how == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = os_lseek_impl(module, fd, position, how);
@ -3741,10 +3836,35 @@ os_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd;
Py_ssize_t length;
if (!_PyArg_ParseStack(args, nargs, "in:read",
&fd, &length)) {
if (!_PyArg_CheckPositional("read", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
length = ival;
}
return_value = os_read_impl(module, fd, length);
exit:
@ -3781,10 +3901,19 @@ os_readv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *buffers;
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO:readv",
&fd, &buffers)) {
if (!_PyArg_CheckPositional("readv", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
buffers = args[1];
_return_value = os_readv_impl(module, fd, buffers);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@ -3822,8 +3951,28 @@ os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int length;
Py_off_t offset;
if (!_PyArg_ParseStack(args, nargs, "iiO&:pread",
&fd, &length, Py_off_t_converter, &offset)) {
if (!_PyArg_CheckPositional("pread", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
length = _PyLong_AsInt(args[1]);
if (length == -1 && PyErr_Occurred()) {
goto exit;
}
if (!Py_off_t_converter(args[2], &offset)) {
goto exit;
}
return_value = os_pread_impl(module, fd, length, offset);
@ -3873,10 +4022,35 @@ os_preadv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int flags = 0;
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iOO&|i:preadv",
&fd, &buffers, Py_off_t_converter, &offset, &flags)) {
if (!_PyArg_CheckPositional("preadv", nargs, 3, 4)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
buffers = args[1];
if (!Py_off_t_converter(args[2], &offset)) {
goto exit;
}
if (nargs < 4) {
goto skip_optional;
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flags = _PyLong_AsInt(args[3]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
_return_value = os_preadv_impl(module, fd, buffers, offset, flags);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@ -3909,8 +4083,23 @@ os_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL};
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iy*:write",
&fd, &data)) {
if (!_PyArg_CheckPositional("write", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("write", 2, "contiguous buffer", args[1]);
goto exit;
}
_return_value = os_write_impl(module, fd, &data);
@ -3950,8 +4139,34 @@ os__fcopyfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int outfd;
int flags;
if (!_PyArg_ParseStack(args, nargs, "iii:_fcopyfile",
&infd, &outfd, &flags)) {
if (!_PyArg_CheckPositional("_fcopyfile", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
infd = _PyLong_AsInt(args[0]);
if (infd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
outfd = _PyLong_AsInt(args[1]);
if (outfd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flags = _PyLong_AsInt(args[2]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os__fcopyfile_impl(module, infd, outfd, flags);
@ -4129,10 +4344,19 @@ os_writev(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *buffers;
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO:writev",
&fd, &buffers)) {
if (!_PyArg_CheckPositional("writev", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
buffers = args[1];
_return_value = os_writev_impl(module, fd, buffers);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@ -4172,8 +4396,26 @@ os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_off_t offset;
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iy*O&:pwrite",
&fd, &buffer, Py_off_t_converter, &offset)) {
if (!_PyArg_CheckPositional("pwrite", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("pwrite", 2, "contiguous buffer", args[1]);
goto exit;
}
if (!Py_off_t_converter(args[2], &offset)) {
goto exit;
}
_return_value = os_pwrite_impl(module, fd, &buffer, offset);
@ -4232,10 +4474,35 @@ os_pwritev(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int flags = 0;
Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iOO&|i:pwritev",
&fd, &buffers, Py_off_t_converter, &offset, &flags)) {
if (!_PyArg_CheckPositional("pwritev", nargs, 3, 4)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
buffers = args[1];
if (!Py_off_t_converter(args[2], &offset)) {
goto exit;
}
if (nargs < 4) {
goto skip_optional;
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flags = _PyLong_AsInt(args[3]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
_return_value = os_pwritev_impl(module, fd, buffers, offset, flags);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@ -4439,8 +4706,25 @@ os_makedev(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int minor;
dev_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:makedev",
&major, &minor)) {
if (!_PyArg_CheckPositional("makedev", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
major = _PyLong_AsInt(args[0]);
if (major == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
minor = _PyLong_AsInt(args[1]);
if (minor == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = os_makedev_impl(module, major, minor);
@ -4476,8 +4760,19 @@ os_ftruncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd;
Py_off_t length;
if (!_PyArg_ParseStack(args, nargs, "iO&:ftruncate",
&fd, Py_off_t_converter, &length)) {
if (!_PyArg_CheckPositional("ftruncate", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (!Py_off_t_converter(args[1], &length)) {
goto exit;
}
return_value = os_ftruncate_impl(module, fd, length);
@ -4555,8 +4850,22 @@ os_posix_fallocate(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_off_t offset;
Py_off_t length;
if (!_PyArg_ParseStack(args, nargs, "iO&O&:posix_fallocate",
&fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) {
if (!_PyArg_CheckPositional("posix_fallocate", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (!Py_off_t_converter(args[1], &offset)) {
goto exit;
}
if (!Py_off_t_converter(args[2], &length)) {
goto exit;
}
return_value = os_posix_fallocate_impl(module, fd, offset, length);
@ -4599,8 +4908,31 @@ os_posix_fadvise(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_off_t length;
int advice;
if (!_PyArg_ParseStack(args, nargs, "iO&O&i:posix_fadvise",
&fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) {
if (!_PyArg_CheckPositional("posix_fadvise", nargs, 4, 4)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (!Py_off_t_converter(args[1], &offset)) {
goto exit;
}
if (!Py_off_t_converter(args[2], &length)) {
goto exit;
}
if (PyFloat_Check(args[3])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
advice = _PyLong_AsInt(args[3]);
if (advice == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_posix_fadvise_impl(module, fd, offset, length, advice);
@ -4632,10 +4964,25 @@ os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *name;
PyObject *value;
if (!_PyArg_ParseStack(args, nargs, "UU:putenv",
&name, &value)) {
if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("putenv", 1, "str", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
name = args[0];
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("putenv", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
value = args[1];
return_value = os_putenv_impl(module, name, value);
exit:
@ -4665,8 +5012,13 @@ os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *name = NULL;
PyObject *value = NULL;
if (!_PyArg_ParseStack(args, nargs, "O&O&:putenv",
PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) {
if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_FSConverter(args[0], &name)) {
goto exit;
}
if (!PyUnicode_FSConverter(args[1], &value)) {
goto exit;
}
return_value = os_putenv_impl(module, name, value);
@ -5208,8 +5560,19 @@ os_fpathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int name;
long _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO&:fpathconf",
&fd, conv_path_confname, &name)) {
if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (!conv_path_confname(args[1], &name)) {
goto exit;
}
_return_value = os_fpathconf_impl(module, fd, name);
@ -5496,8 +5859,16 @@ os_setresuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
uid_t euid;
uid_t suid;
if (!_PyArg_ParseStack(args, nargs, "O&O&O&:setresuid",
_Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) {
if (!_PyArg_CheckPositional("setresuid", nargs, 3, 3)) {
goto exit;
}
if (!_Py_Uid_Converter(args[0], &ruid)) {
goto exit;
}
if (!_Py_Uid_Converter(args[1], &euid)) {
goto exit;
}
if (!_Py_Uid_Converter(args[2], &suid)) {
goto exit;
}
return_value = os_setresuid_impl(module, ruid, euid, suid);
@ -5530,8 +5901,16 @@ os_setresgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
gid_t egid;
gid_t sgid;
if (!_PyArg_ParseStack(args, nargs, "O&O&O&:setresgid",
_Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) {
if (!_PyArg_CheckPositional("setresgid", nargs, 3, 3)) {
goto exit;
}
if (!_Py_Gid_Converter(args[0], &rgid)) {
goto exit;
}
if (!_Py_Gid_Converter(args[1], &egid)) {
goto exit;
}
if (!_Py_Gid_Converter(args[2], &sgid)) {
goto exit;
}
return_value = os_setresgid_impl(module, rgid, egid, sgid);
@ -5898,8 +6277,25 @@ os_set_inheritable(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd;
int inheritable;
if (!_PyArg_ParseStack(args, nargs, "ii:set_inheritable",
&fd, &inheritable)) {
if (!_PyArg_CheckPositional("set_inheritable", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
inheritable = _PyLong_AsInt(args[1]);
if (inheritable == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_set_inheritable_impl(module, fd, inheritable);
@ -6046,8 +6442,25 @@ os_set_blocking(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd;
int blocking;
if (!_PyArg_ParseStack(args, nargs, "ii:set_blocking",
&fd, &blocking)) {
if (!_PyArg_CheckPositional("set_blocking", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
blocking = _PyLong_AsInt(args[1]);
if (blocking == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_set_blocking_impl(module, fd, blocking);
@ -6845,4 +7258,4 @@ exit:
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
/*[clinic end generated code: output=b02036b2a269b1db input=a9049054013a1b77]*/
/*[clinic end generated code: output=febc1e16c9024e40 input=a9049054013a1b77]*/

View File

@ -34,7 +34,7 @@ pwd_getpwnam(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("getpwnam", "str", arg);
_PyArg_BadArgument("getpwnam", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -74,4 +74,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef PWD_GETPWALL_METHODDEF
#define PWD_GETPWALL_METHODDEF
#endif /* !defined(PWD_GETPWALL_METHODDEF) */
/*[clinic end generated code: output=9e86e23d6ad9cd08 input=a9049054013a1b77]*/
/*[clinic end generated code: output=f9412bdedc69706c input=a9049054013a1b77]*/

View File

@ -24,10 +24,23 @@ pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *const *args, Py_ssize_t
PyObject *data;
int isfinal = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:Parse",
&data, &isfinal)) {
if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) {
goto exit;
}
data = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
isfinal = _PyLong_AsInt(args[1]);
if (isfinal == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal);
exit:
@ -62,7 +75,7 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
const char *base;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("SetBase", "str", arg);
_PyArg_BadArgument("SetBase", 0, "str", arg);
goto exit;
}
Py_ssize_t base_length;
@ -140,10 +153,44 @@ pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *con
const char *context;
const char *encoding = NULL;
if (!_PyArg_ParseStack(args, nargs, "z|s:ExternalEntityParserCreate",
&context, &encoding)) {
if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) {
goto exit;
}
if (args[0] == Py_None) {
context = NULL;
}
else if (PyUnicode_Check(args[0])) {
Py_ssize_t context_length;
context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
if (context == NULL) {
goto exit;
}
if (strlen(context) != (size_t)context_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
_PyArg_BadArgument("ExternalEntityParserCreate", 1, "str or None", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("ExternalEntityParserCreate", 2, "str", args[1]);
goto exit;
}
Py_ssize_t encoding_length;
encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
if (encoding == NULL) {
goto exit;
}
if (strlen(encoding) != (size_t)encoding_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
skip_optional:
return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding);
exit:
@ -212,10 +259,17 @@ pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *const *args, Py_
PyObject *return_value = NULL;
int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|p:UseForeignDTD",
&flag)) {
if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
flag = PyObject_IsTrue(args[0]);
if (flag < 0) {
goto exit;
}
skip_optional:
return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag);
exit:
@ -294,4 +348,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
/*[clinic end generated code: output=d3750256eb0da1cb input=a9049054013a1b77]*/
/*[clinic end generated code: output=0f18b756d82b78a5 input=a9049054013a1b77]*/

View File

@ -84,10 +84,19 @@ resource_setrlimit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int resource;
PyObject *limits;
if (!_PyArg_ParseStack(args, nargs, "iO:setrlimit",
&resource, &limits)) {
if (!_PyArg_CheckPositional("setrlimit", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
resource = _PyLong_AsInt(args[0]);
if (resource == -1 && PyErr_Occurred()) {
goto exit;
}
limits = args[1];
return_value = resource_setrlimit_impl(module, resource, limits);
exit:
@ -169,4 +178,4 @@ exit:
#ifndef RESOURCE_PRLIMIT_METHODDEF
#define RESOURCE_PRLIMIT_METHODDEF
#endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */
/*[clinic end generated code: output=b16a9149639081fd input=a9049054013a1b77]*/
/*[clinic end generated code: output=ef3034f291156a34 input=a9049054013a1b77]*/

View File

@ -82,10 +82,19 @@ select_poll_register(pollObject *self, PyObject *const *args, Py_ssize_t nargs)
int fd;
unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;
if (!_PyArg_ParseStack(args, nargs, "O&|O&:register",
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
if (!_PyArg_CheckPositional("register", nargs, 1, 2)) {
goto exit;
}
if (!fildes_converter(args[0], &fd)) {
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) {
goto exit;
}
skip_optional:
return_value = select_poll_register_impl(self, fd, eventmask);
exit:
@ -121,8 +130,13 @@ select_poll_modify(pollObject *self, PyObject *const *args, Py_ssize_t nargs)
int fd;
unsigned short eventmask;
if (!_PyArg_ParseStack(args, nargs, "O&O&:modify",
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
if (!_PyArg_CheckPositional("modify", nargs, 2, 2)) {
goto exit;
}
if (!fildes_converter(args[0], &fd)) {
goto exit;
}
if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) {
goto exit;
}
return_value = select_poll_modify_impl(self, fd, eventmask);
@ -228,10 +242,19 @@ select_devpoll_register(devpollObject *self, PyObject *const *args, Py_ssize_t n
int fd;
unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;
if (!_PyArg_ParseStack(args, nargs, "O&|O&:register",
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
if (!_PyArg_CheckPositional("register", nargs, 1, 2)) {
goto exit;
}
if (!fildes_converter(args[0], &fd)) {
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) {
goto exit;
}
skip_optional:
return_value = select_devpoll_register_impl(self, fd, eventmask);
exit:
@ -268,10 +291,19 @@ select_devpoll_modify(devpollObject *self, PyObject *const *args, Py_ssize_t nar
int fd;
unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;
if (!_PyArg_ParseStack(args, nargs, "O&|O&:modify",
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
if (!_PyArg_CheckPositional("modify", nargs, 1, 2)) {
goto exit;
}
if (!fildes_converter(args[0], &fd)) {
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) {
goto exit;
}
skip_optional:
return_value = select_devpoll_modify_impl(self, fd, eventmask);
exit:
@ -948,10 +980,24 @@ select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize
int maxevents;
PyObject *otimeout = Py_None;
if (!_PyArg_ParseStack(args, nargs, "Oi|O:control",
&changelist, &maxevents, &otimeout)) {
if (!_PyArg_CheckPositional("control", nargs, 2, 3)) {
goto exit;
}
changelist = args[0];
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
maxevents = _PyLong_AsInt(args[1]);
if (maxevents == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
otimeout = args[2];
skip_optional:
return_value = select_kqueue_control_impl(self, changelist, maxevents, otimeout);
exit:
@ -1059,4 +1105,4 @@ exit:
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
#define SELECT_KQUEUE_CONTROL_METHODDEF
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
/*[clinic end generated code: output=122a49f131cdd9d9 input=a9049054013a1b77]*/
/*[clinic end generated code: output=20da8f9c050e1b65 input=a9049054013a1b77]*/

View File

@ -125,10 +125,19 @@ signal_signal(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int signalnum;
PyObject *handler;
if (!_PyArg_ParseStack(args, nargs, "iO:signal",
&signalnum, &handler)) {
if (!_PyArg_CheckPositional("signal", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
signalnum = _PyLong_AsInt(args[0]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
handler = args[1];
return_value = signal_signal_impl(module, signalnum, handler);
exit:
@ -234,8 +243,25 @@ signal_siginterrupt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int signalnum;
int flag;
if (!_PyArg_ParseStack(args, nargs, "ii:siginterrupt",
&signalnum, &flag)) {
if (!_PyArg_CheckPositional("siginterrupt", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
signalnum = _PyLong_AsInt(args[0]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(args[1]);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_siginterrupt_impl(module, signalnum, flag);
@ -274,10 +300,24 @@ signal_setitimer(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *seconds;
PyObject *interval = NULL;
if (!_PyArg_ParseStack(args, nargs, "iO|O:setitimer",
&which, &seconds, &interval)) {
if (!_PyArg_CheckPositional("setitimer", nargs, 2, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
which = _PyLong_AsInt(args[0]);
if (which == -1 && PyErr_Occurred()) {
goto exit;
}
seconds = args[1];
if (nargs < 3) {
goto skip_optional;
}
interval = args[2];
skip_optional:
return_value = signal_setitimer_impl(module, which, seconds, interval);
exit:
@ -344,8 +384,19 @@ signal_pthread_sigmask(PyObject *module, PyObject *const *args, Py_ssize_t nargs
int how;
sigset_t mask;
if (!_PyArg_ParseStack(args, nargs, "iO&:pthread_sigmask",
&how, _Py_Sigset_Converter, &mask)) {
if (!_PyArg_CheckPositional("pthread_sigmask", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
how = _PyLong_AsInt(args[0]);
if (how == -1 && PyErr_Occurred()) {
goto exit;
}
if (!_Py_Sigset_Converter(args[1], &mask)) {
goto exit;
}
return_value = signal_pthread_sigmask_impl(module, how, mask);
@ -498,10 +549,13 @@ signal_sigtimedwait(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
sigset_t sigset;
PyObject *timeout_obj;
if (!_PyArg_ParseStack(args, nargs, "O&O:sigtimedwait",
_Py_Sigset_Converter, &sigset, &timeout_obj)) {
if (!_PyArg_CheckPositional("sigtimedwait", nargs, 2, 2)) {
goto exit;
}
if (!_Py_Sigset_Converter(args[0], &sigset)) {
goto exit;
}
timeout_obj = args[1];
return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj);
exit:
@ -532,8 +586,21 @@ signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
unsigned long thread_id;
int signalnum;
if (!_PyArg_ParseStack(args, nargs, "ki:pthread_kill",
&thread_id, &signalnum)) {
if (!_PyArg_CheckPositional("pthread_kill", nargs, 2, 2)) {
goto exit;
}
if (!PyLong_Check(args[0])) {
_PyArg_BadArgument("pthread_kill", 1, "int", args[0]);
goto exit;
}
thread_id = PyLong_AsUnsignedLongMask(args[0]);
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
signalnum = _PyLong_AsInt(args[1]);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_pthread_kill_impl(module, thread_id, signalnum);
@ -591,4 +658,4 @@ exit:
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
#define SIGNAL_PTHREAD_KILL_METHODDEF
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
/*[clinic end generated code: output=365db4e807c26d4e input=a9049054013a1b77]*/
/*[clinic end generated code: output=f0d3a5703581da76 input=a9049054013a1b77]*/

View File

@ -25,7 +25,7 @@ spwd_getspnam(PyObject *module, PyObject *arg_)
PyObject *arg;
if (!PyUnicode_Check(arg_)) {
_PyArg_BadArgument("getspnam", "str", arg_);
_PyArg_BadArgument("getspnam", 0, "str", arg_);
goto exit;
}
if (PyUnicode_READY(arg_) == -1) {
@ -71,4 +71,4 @@ spwd_getspall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef SPWD_GETSPALL_METHODDEF
#define SPWD_GETSPALL_METHODDEF
#endif /* !defined(SPWD_GETSPALL_METHODDEF) */
/*[clinic end generated code: output=44a7c196d4b48f4e input=a9049054013a1b77]*/
/*[clinic end generated code: output=2bbaa6bab1d9116e input=a9049054013a1b77]*/

View File

@ -23,8 +23,36 @@ _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *filename;
const char *startstr;
if (!_PyArg_ParseStack(args, nargs, "sO&s:symtable",
&str, PyUnicode_FSDecoder, &filename, &startstr)) {
if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("symtable", 1, "str", args[0]);
goto exit;
}
Py_ssize_t str_length;
str = PyUnicode_AsUTF8AndSize(args[0], &str_length);
if (str == NULL) {
goto exit;
}
if (strlen(str) != (size_t)str_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (!PyUnicode_FSDecoder(args[1], &filename)) {
goto exit;
}
if (!PyUnicode_Check(args[2])) {
_PyArg_BadArgument("symtable", 3, "str", args[2]);
goto exit;
}
Py_ssize_t startstr_length;
startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length);
if (startstr == NULL) {
goto exit;
}
if (strlen(startstr) != (size_t)startstr_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _symtable_symtable_impl(module, str, filename, startstr);
@ -32,4 +60,4 @@ _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=52ece07dd0e7a113 input=a9049054013a1b77]*/
/*[clinic end generated code: output=be1cca59de019984 input=a9049054013a1b77]*/

View File

@ -26,10 +26,26 @@ unicodedata_UCD_decimal(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr;
PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:decimal",
&chr, &default_value)) {
if (!_PyArg_CheckPositional("decimal", nargs, 1, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("decimal", 1, "a unicode character", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0])) {
goto exit;
}
if (PyUnicode_GET_LENGTH(args[0]) != 1) {
_PyArg_BadArgument("decimal", 1, "a unicode character", args[0]);
goto exit;
}
chr = PyUnicode_READ_CHAR(args[0], 0);
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
exit:
@ -59,10 +75,26 @@ unicodedata_UCD_digit(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr;
PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:digit",
&chr, &default_value)) {
if (!_PyArg_CheckPositional("digit", nargs, 1, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("digit", 1, "a unicode character", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0])) {
goto exit;
}
if (PyUnicode_GET_LENGTH(args[0]) != 1) {
_PyArg_BadArgument("digit", 1, "a unicode character", args[0]);
goto exit;
}
chr = PyUnicode_READ_CHAR(args[0], 0);
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
exit:
@ -93,10 +125,26 @@ unicodedata_UCD_numeric(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr;
PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:numeric",
&chr, &default_value)) {
if (!_PyArg_CheckPositional("numeric", nargs, 1, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("numeric", 1, "a unicode character", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0])) {
goto exit;
}
if (PyUnicode_GET_LENGTH(args[0]) != 1) {
_PyArg_BadArgument("numeric", 1, "a unicode character", args[0]);
goto exit;
}
chr = PyUnicode_READ_CHAR(args[0], 0);
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
exit:
@ -122,14 +170,14 @@ unicodedata_UCD_category(PyObject *self, PyObject *arg)
int chr;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("category", "a unicode character", arg);
_PyArg_BadArgument("category", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("category", "a unicode character", arg);
_PyArg_BadArgument("category", 0, "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
@ -160,14 +208,14 @@ unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
int chr;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("bidirectional", "a unicode character", arg);
_PyArg_BadArgument("bidirectional", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("bidirectional", "a unicode character", arg);
_PyArg_BadArgument("bidirectional", 0, "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
@ -199,14 +247,14 @@ unicodedata_UCD_combining(PyObject *self, PyObject *arg)
int _return_value;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("combining", "a unicode character", arg);
_PyArg_BadArgument("combining", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("combining", "a unicode character", arg);
_PyArg_BadArgument("combining", 0, "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
@ -243,14 +291,14 @@ unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
int _return_value;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("mirrored", "a unicode character", arg);
_PyArg_BadArgument("mirrored", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("mirrored", "a unicode character", arg);
_PyArg_BadArgument("mirrored", 0, "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
@ -283,14 +331,14 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
int chr;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("east_asian_width", "a unicode character", arg);
_PyArg_BadArgument("east_asian_width", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("east_asian_width", "a unicode character", arg);
_PyArg_BadArgument("east_asian_width", 0, "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
@ -321,14 +369,14 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
int chr;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("decomposition", "a unicode character", arg);
_PyArg_BadArgument("decomposition", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("decomposition", "a unicode character", arg);
_PyArg_BadArgument("decomposition", 0, "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
@ -360,10 +408,25 @@ unicodedata_UCD_is_normalized(PyObject *self, PyObject *const *args, Py_ssize_t
PyObject *form;
PyObject *input;
if (!_PyArg_ParseStack(args, nargs, "UU:is_normalized",
&form, &input)) {
if (!_PyArg_CheckPositional("is_normalized", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("is_normalized", 1, "str", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
form = args[0];
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("is_normalized", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
input = args[1];
return_value = unicodedata_UCD_is_normalized_impl(self, form, input);
exit:
@ -392,10 +455,25 @@ unicodedata_UCD_normalize(PyObject *self, PyObject *const *args, Py_ssize_t narg
PyObject *form;
PyObject *input;
if (!_PyArg_ParseStack(args, nargs, "UU:normalize",
&form, &input)) {
if (!_PyArg_CheckPositional("normalize", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("normalize", 1, "str", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
form = args[0];
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("normalize", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
input = args[1];
return_value = unicodedata_UCD_normalize_impl(self, form, input);
exit:
@ -424,10 +502,26 @@ unicodedata_UCD_name(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr;
PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:name",
&chr, &default_value)) {
if (!_PyArg_CheckPositional("name", nargs, 1, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("name", 1, "a unicode character", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0])) {
goto exit;
}
if (PyUnicode_GET_LENGTH(args[0]) != 1) {
_PyArg_BadArgument("name", 1, "a unicode character", args[0]);
goto exit;
}
chr = PyUnicode_READ_CHAR(args[0], 0);
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
return_value = unicodedata_UCD_name_impl(self, chr, default_value);
exit:
@ -465,4 +559,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=709241b99d010896 input=a9049054013a1b77]*/
/*[clinic end generated code: output=0fc850fe5b6b312c input=a9049054013a1b77]*/

View File

@ -219,7 +219,7 @@ zlib_Compress_compress(compobject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg);
_PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit;
}
return_value = zlib_Compress_compress_impl(self, &data);
@ -305,10 +305,22 @@ zlib_Compress_flush(compobject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int mode = Z_FINISH;
if (!_PyArg_ParseStack(args, nargs, "|i:flush",
&mode)) {
if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[0]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = zlib_Compress_flush_impl(self, mode);
exit:
@ -446,10 +458,16 @@ zlib_Decompress_flush(compobject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t length = DEF_BUF_SIZE;
if (!_PyArg_ParseStack(args, nargs, "|O&:flush",
ssize_t_converter, &length)) {
if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!ssize_t_converter(args[0], &length)) {
goto exit;
}
skip_optional:
return_value = zlib_Decompress_flush_impl(self, length);
exit:
@ -480,10 +498,29 @@ zlib_adler32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL};
unsigned int value = 1;
if (!_PyArg_ParseStack(args, nargs, "y*|I:adler32",
&data, &value)) {
if (!_PyArg_CheckPositional("adler32", nargs, 1, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("adler32", 1, "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
if (value == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = zlib_adler32_impl(module, &data, value);
exit:
@ -519,10 +556,29 @@ zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL};
unsigned int value = 0;
if (!_PyArg_ParseStack(args, nargs, "y*|I:crc32",
&data, &value)) {
if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("crc32", 1, "contiguous buffer", args[0]);
goto exit;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
if (value == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = zlib_crc32_impl(module, &data, value);
exit:
@ -557,4 +613,4 @@ exit:
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
/*[clinic end generated code: output=bea1e3c64573d9fd input=a9049054013a1b77]*/
/*[clinic end generated code: output=b3acec2384f18782 input=a9049054013a1b77]*/

View File

@ -100,8 +100,21 @@ bytearray_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
Py_buffer frm = {NULL, NULL};
Py_buffer to = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans",
&frm, &to)) {
if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&frm, 'C')) {
_PyArg_BadArgument("maketrans", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&to, 'C')) {
_PyArg_BadArgument("maketrans", 2, "contiguous buffer", args[1]);
goto exit;
}
return_value = bytearray_maketrans_impl(&frm, &to);
@ -147,10 +160,44 @@ bytearray_replace(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nar
Py_buffer new = {NULL, NULL};
Py_ssize_t count = -1;
if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace",
&old, &new, &count)) {
if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&old, 'C')) {
_PyArg_BadArgument("replace", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&new, 'C')) {
_PyArg_BadArgument("replace", 2, "contiguous buffer", args[1]);
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
count = ival;
}
skip_optional:
return_value = bytearray_replace_impl(self, &old, &new, count);
exit:
@ -323,8 +370,27 @@ bytearray_insert(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg
Py_ssize_t index;
int item;
if (!_PyArg_ParseStack(args, nargs, "nO&:insert",
&index, _getbytevalue, &item)) {
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
if (!_getbytevalue(args[1], &item)) {
goto exit;
}
return_value = bytearray_insert_impl(self, index, item);
@ -399,10 +465,30 @@ bytearray_pop(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t index = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:pop",
&index)) {
if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
skip_optional:
return_value = bytearray_pop_impl(self, index);
exit:
@ -641,7 +727,7 @@ bytearray_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *string;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", "str", arg);
_PyArg_BadArgument("fromhex", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -690,10 +776,22 @@ bytearray_reduce_ex(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t n
PyObject *return_value = NULL;
int proto = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:__reduce_ex__",
&proto)) {
if (!_PyArg_CheckPositional("__reduce_ex__", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
proto = _PyLong_AsInt(args[0]);
if (proto == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = bytearray_reduce_ex_impl(self, proto);
exit:
@ -717,4 +815,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
/*[clinic end generated code: output=cd3e13a1905a473c input=a9049054013a1b77]*/
/*[clinic end generated code: output=010e281b823d7df1 input=a9049054013a1b77]*/

View File

@ -70,7 +70,7 @@ bytes_partition(PyBytesObject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("partition", "contiguous buffer", arg);
_PyArg_BadArgument("partition", 0, "contiguous buffer", arg);
goto exit;
}
return_value = bytes_partition_impl(self, &sep);
@ -113,7 +113,7 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("rpartition", "contiguous buffer", arg);
_PyArg_BadArgument("rpartition", 0, "contiguous buffer", arg);
goto exit;
}
return_value = bytes_rpartition_impl(self, &sep);
@ -338,8 +338,21 @@ bytes_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
Py_buffer frm = {NULL, NULL};
Py_buffer to = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans",
&frm, &to)) {
if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &frm, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&frm, 'C')) {
_PyArg_BadArgument("maketrans", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &to, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&to, 'C')) {
_PyArg_BadArgument("maketrans", 2, "contiguous buffer", args[1]);
goto exit;
}
return_value = bytes_maketrans_impl(&frm, &to);
@ -385,10 +398,44 @@ bytes_replace(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_buffer new = {NULL, NULL};
Py_ssize_t count = -1;
if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace",
&old, &new, &count)) {
if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
goto exit;
}
if (PyObject_GetBuffer(args[0], &old, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&old, 'C')) {
_PyArg_BadArgument("replace", 1, "contiguous buffer", args[0]);
goto exit;
}
if (PyObject_GetBuffer(args[1], &new, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&new, 'C')) {
_PyArg_BadArgument("replace", 2, "contiguous buffer", args[1]);
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
count = ival;
}
skip_optional:
return_value = bytes_replace_impl(self, &old, &new, count);
exit:
@ -500,7 +547,7 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *string;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", "str", arg);
_PyArg_BadArgument("fromhex", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -512,4 +559,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=dc9aa04f0007ab11 input=a9049054013a1b77]*/
/*[clinic end generated code: output=810c8dfc72520ca4 input=a9049054013a1b77]*/

View File

@ -229,7 +229,7 @@ float___getformat__(PyTypeObject *type, PyObject *arg)
const char *typestr;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__getformat__", "str", arg);
_PyArg_BadArgument("__getformat__", 0, "str", arg);
goto exit;
}
Py_ssize_t typestr_length;
@ -279,8 +279,33 @@ float___set_format__(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs
const char *typestr;
const char *fmt;
if (!_PyArg_ParseStack(args, nargs, "ss:__set_format__",
&typestr, &fmt)) {
if (!_PyArg_CheckPositional("__set_format__", nargs, 2, 2)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("__set_format__", 1, "str", args[0]);
goto exit;
}
Py_ssize_t typestr_length;
typestr = PyUnicode_AsUTF8AndSize(args[0], &typestr_length);
if (typestr == NULL) {
goto exit;
}
if (strlen(typestr) != (size_t)typestr_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("__set_format__", 2, "str", args[1]);
goto exit;
}
Py_ssize_t fmt_length;
fmt = PyUnicode_AsUTF8AndSize(args[1], &fmt_length);
if (fmt == NULL) {
goto exit;
}
if (strlen(fmt) != (size_t)fmt_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = float___set_format___impl(type, typestr, fmt);
@ -308,7 +333,7 @@ float___format__(PyObject *self, PyObject *arg)
PyObject *format_spec;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
_PyArg_BadArgument("__format__", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -320,4 +345,4 @@ float___format__(PyObject *self, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/
/*[clinic end generated code: output=2631a60701a8f7d4 input=a9049054013a1b77]*/

View File

@ -21,10 +21,27 @@ list_insert(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t index;
PyObject *object;
if (!_PyArg_ParseStack(args, nargs, "nO:insert",
&index, &object)) {
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
object = args[1];
return_value = list_insert_impl(self, index, object);
exit:
@ -105,10 +122,30 @@ list_pop(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
Py_ssize_t index = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:pop",
&index)) {
if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
index = ival;
}
skip_optional:
return_value = list_pop_impl(self, index);
exit:
@ -187,10 +224,23 @@ list_index(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t start = 0;
Py_ssize_t stop = PY_SSIZE_T_MAX;
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index",
&value, _PyEval_SliceIndexNotNone, &start, _PyEval_SliceIndexNotNone, &stop)) {
if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
goto exit;
}
value = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
goto exit;
}
skip_optional:
return_value = list_index_impl(self, value, start, stop);
exit:
@ -285,4 +335,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
{
return list___reversed___impl(self);
}
/*[clinic end generated code: output=652ae4ee63a9de71 input=a9049054013a1b77]*/
/*[clinic end generated code: output=1f641f5aef3f886f input=a9049054013a1b77]*/

View File

@ -59,7 +59,7 @@ int___format__(PyObject *self, PyObject *arg)
PyObject *format_spec;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
_PyArg_BadArgument("__format__", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -244,4 +244,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb
exit:
return return_value;
}
/*[clinic end generated code: output=7436b5f4decdcf9d input=a9049054013a1b77]*/
/*[clinic end generated code: output=3b91cda9d83abaa2 input=a9049054013a1b77]*/

View File

@ -25,10 +25,23 @@ tuple_index(PyTupleObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t start = 0;
Py_ssize_t stop = PY_SSIZE_T_MAX;
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index",
&value, _PyEval_SliceIndexNotNone, &start, _PyEval_SliceIndexNotNone, &stop)) {
if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
goto exit;
}
value = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
goto exit;
}
skip_optional:
return_value = tuple_index_impl(self, value, start, stop);
exit:
@ -95,4 +108,4 @@ tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored))
{
return tuple___getnewargs___impl(self);
}
/*[clinic end generated code: output=0a6ebd2d16b09c5d input=a9049054013a1b77]*/
/*[clinic end generated code: output=5312868473a41cfe input=a9049054013a1b77]*/

View File

@ -200,7 +200,7 @@ object___format__(PyObject *self, PyObject *arg)
PyObject *format_spec;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
_PyArg_BadArgument("__format__", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -248,4 +248,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return object___dir___impl(self);
}
/*[clinic end generated code: output=09f3453839e60136 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ea5734413064fa7e input=a9049054013a1b77]*/

View File

@ -83,10 +83,33 @@ unicode_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width;
Py_UCS4 fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|O&:center",
&width, convert_uc, &fillchar)) {
if (!_PyArg_CheckPositional("center", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (!convert_uc(args[1], &fillchar)) {
goto exit;
}
skip_optional:
return_value = unicode_center_impl(self, width, fillchar);
exit:
@ -452,10 +475,33 @@ unicode_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width;
Py_UCS4 fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|O&:ljust",
&width, convert_uc, &fillchar)) {
if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (!convert_uc(args[1], &fillchar)) {
goto exit;
}
skip_optional:
return_value = unicode_ljust_impl(self, width, fillchar);
exit:
@ -601,10 +647,46 @@ unicode_replace(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *new;
Py_ssize_t count = -1;
if (!_PyArg_ParseStack(args, nargs, "UU|n:replace",
&old, &new, &count)) {
if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
goto exit;
}
if (!PyUnicode_Check(args[0])) {
_PyArg_BadArgument("replace", 1, "str", args[0]);
goto exit;
}
if (PyUnicode_READY(args[0]) == -1) {
goto exit;
}
old = args[0];
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("replace", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
new = args[1];
if (nargs < 3) {
goto skip_optional;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[2]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
count = ival;
}
skip_optional:
return_value = unicode_replace_impl(self, old, new, count);
exit:
@ -632,10 +714,33 @@ unicode_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width;
Py_UCS4 fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|O&:rjust",
&width, convert_uc, &fillchar)) {
if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (!convert_uc(args[1], &fillchar)) {
goto exit;
}
skip_optional:
return_value = unicode_rjust_impl(self, width, fillchar);
exit:
@ -833,10 +938,33 @@ unicode_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
PyObject *y = NULL;
PyObject *z = NULL;
if (!_PyArg_ParseStack(args, nargs, "O|UU:maketrans",
&x, &y, &z)) {
if (!_PyArg_CheckPositional("maketrans", nargs, 1, 3)) {
goto exit;
}
x = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("maketrans", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
y = args[1];
if (nargs < 3) {
goto skip_optional;
}
if (!PyUnicode_Check(args[2])) {
_PyArg_BadArgument("maketrans", 3, "str", args[2]);
goto exit;
}
if (PyUnicode_READY(args[2]) == -1) {
goto exit;
}
z = args[2];
skip_optional:
return_value = unicode_maketrans_impl(x, y, z);
exit:
@ -940,7 +1068,7 @@ unicode___format__(PyObject *self, PyObject *arg)
PyObject *format_spec;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
_PyArg_BadArgument("__format__", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -970,4 +1098,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return unicode_sizeof_impl(self);
}
/*[clinic end generated code: output=ff6acd5abd1998eb input=a9049054013a1b77]*/
/*[clinic end generated code: output=73ad9670e00a2490 input=a9049054013a1b77]*/

View File

@ -55,10 +55,40 @@ stringlib_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width;
char fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|c:ljust",
&width, &fillchar)) {
if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyBytes_Check(args[1]) && PyBytes_GET_SIZE(args[1]) == 1) {
fillchar = PyBytes_AS_STRING(args[1])[0];
}
else if (PyByteArray_Check(args[1]) && PyByteArray_GET_SIZE(args[1]) == 1) {
fillchar = PyByteArray_AS_STRING(args[1])[0];
}
else {
_PyArg_BadArgument("ljust", 2, "a byte string of length 1", args[1]);
goto exit;
}
skip_optional:
return_value = stringlib_ljust_impl(self, width, fillchar);
exit:
@ -86,10 +116,40 @@ stringlib_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width;
char fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|c:rjust",
&width, &fillchar)) {
if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyBytes_Check(args[1]) && PyBytes_GET_SIZE(args[1]) == 1) {
fillchar = PyBytes_AS_STRING(args[1])[0];
}
else if (PyByteArray_Check(args[1]) && PyByteArray_GET_SIZE(args[1]) == 1) {
fillchar = PyByteArray_AS_STRING(args[1])[0];
}
else {
_PyArg_BadArgument("rjust", 2, "a byte string of length 1", args[1]);
goto exit;
}
skip_optional:
return_value = stringlib_rjust_impl(self, width, fillchar);
exit:
@ -117,10 +177,40 @@ stringlib_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width;
char fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|c:center",
&width, &fillchar)) {
if (!_PyArg_CheckPositional("center", nargs, 1, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
if (nargs < 2) {
goto skip_optional;
}
if (PyBytes_Check(args[1]) && PyBytes_GET_SIZE(args[1]) == 1) {
fillchar = PyBytes_AS_STRING(args[1])[0];
}
else if (PyByteArray_Check(args[1]) && PyByteArray_GET_SIZE(args[1]) == 1) {
fillchar = PyByteArray_AS_STRING(args[1])[0];
}
else {
_PyArg_BadArgument("center", 2, "a byte string of length 1", args[1]);
goto exit;
}
skip_optional:
return_value = stringlib_center_impl(self, width, fillchar);
exit:
@ -169,4 +259,4 @@ stringlib_zfill(PyObject *self, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=bf2ef501639e1190 input=a9049054013a1b77]*/
/*[clinic end generated code: output=787248a980f6a00e input=a9049054013a1b77]*/

View File

@ -50,8 +50,34 @@ msvcrt_locking(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int mode;
long nbytes;
if (!_PyArg_ParseStack(args, nargs, "iil:locking",
&fd, &mode, &nbytes)) {
if (!_PyArg_CheckPositional("locking", nargs, 3, 3)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[1]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nbytes = PyLong_AsLong(args[2]);
if (nbytes == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = msvcrt_locking_impl(module, fd, mode, nbytes);
@ -85,8 +111,25 @@ msvcrt_setmode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int flags;
long _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:setmode",
&fd, &flags)) {
if (!_PyArg_CheckPositional("setmode", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(args[0]);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flags = _PyLong_AsInt(args[1]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = msvcrt_setmode_impl(module, fd, flags);
@ -332,7 +375,7 @@ msvcrt_putch(PyObject *module, PyObject *arg)
char_value = PyByteArray_AS_STRING(arg)[0];
}
else {
_PyArg_BadArgument("putch", "a byte string of length 1", arg);
_PyArg_BadArgument("putch", 0, "a byte string of length 1", arg);
goto exit;
}
return_value = msvcrt_putch_impl(module, char_value);
@ -360,14 +403,14 @@ msvcrt_putwch(PyObject *module, PyObject *arg)
int unicode_char;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("putwch", "a unicode character", arg);
_PyArg_BadArgument("putwch", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("putwch", "a unicode character", arg);
_PyArg_BadArgument("putwch", 0, "a unicode character", arg);
goto exit;
}
unicode_char = PyUnicode_READ_CHAR(arg, 0);
@ -406,7 +449,7 @@ msvcrt_ungetch(PyObject *module, PyObject *arg)
char_value = PyByteArray_AS_STRING(arg)[0];
}
else {
_PyArg_BadArgument("ungetch", "a byte string of length 1", arg);
_PyArg_BadArgument("ungetch", 0, "a byte string of length 1", arg);
goto exit;
}
return_value = msvcrt_ungetch_impl(module, char_value);
@ -434,14 +477,14 @@ msvcrt_ungetwch(PyObject *module, PyObject *arg)
int unicode_char;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("ungetwch", "a unicode character", arg);
_PyArg_BadArgument("ungetwch", 0, "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("ungetwch", "a unicode character", arg);
_PyArg_BadArgument("ungetwch", 0, "a unicode character", arg);
goto exit;
}
unicode_char = PyUnicode_READ_CHAR(arg, 0);
@ -515,8 +558,25 @@ msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t narg
int mode;
long _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportMode",
&type, &mode)) {
if (!_PyArg_CheckPositional("CrtSetReportMode", nargs, 2, 2)) {
goto exit;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
type = _PyLong_AsInt(args[0]);
if (type == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(args[1]);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
@ -619,4 +679,4 @@ exit:
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
#define MSVCRT_SET_ERROR_MODE_METHODDEF
#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
/*[clinic end generated code: output=2530b4ff248563b4 input=a9049054013a1b77]*/
/*[clinic end generated code: output=816bc4f993893cea input=a9049054013a1b77]*/

32
PC/clinic/winreg.c.h generated
View File

@ -425,8 +425,19 @@ winreg_EnumKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
HKEY key;
int index;
if (!_PyArg_ParseStack(args, nargs, "O&i:EnumKey",
clinic_HKEY_converter, &key, &index)) {
if (!_PyArg_CheckPositional("EnumKey", nargs, 2, 2)) {
goto exit;
}
if (!clinic_HKEY_converter(args[0], &key)) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
index = _PyLong_AsInt(args[1]);
if (index == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = winreg_EnumKey_impl(module, key, index);
@ -472,8 +483,19 @@ winreg_EnumValue(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
HKEY key;
int index;
if (!_PyArg_ParseStack(args, nargs, "O&i:EnumValue",
clinic_HKEY_converter, &key, &index)) {
if (!_PyArg_CheckPositional("EnumValue", nargs, 2, 2)) {
goto exit;
}
if (!clinic_HKEY_converter(args[0], &key)) {
goto exit;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
index = _PyLong_AsInt(args[1]);
if (index == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = winreg_EnumValue_impl(module, key, index);
@ -1095,4 +1117,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=82bd56c524c6c3dd input=a9049054013a1b77]*/
/*[clinic end generated code: output=bd491131d343ae7a input=a9049054013a1b77]*/

View File

@ -94,10 +94,22 @@ builtin_format(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *value;
PyObject *format_spec = NULL;
if (!_PyArg_ParseStack(args, nargs, "O|U:format",
&value, &format_spec)) {
if (!_PyArg_CheckPositional("format", nargs, 1, 2)) {
goto exit;
}
value = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("format", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
format_spec = args[1];
skip_optional:
return_value = builtin_format_impl(module, value, format_spec);
exit:
@ -717,4 +729,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/
/*[clinic end generated code: output=11b5cd918bd7eb18 input=a9049054013a1b77]*/

View File

@ -88,10 +88,22 @@ _imp__fix_co_filename(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyCodeObject *code;
PyObject *path;
if (!_PyArg_ParseStack(args, nargs, "O!U:_fix_co_filename",
&PyCode_Type, &code, &path)) {
if (!_PyArg_CheckPositional("_fix_co_filename", nargs, 2, 2)) {
goto exit;
}
if (!PyObject_TypeCheck(args[0], &PyCode_Type)) {
_PyArg_BadArgument("_fix_co_filename", 1, (&PyCode_Type)->tp_name, args[0]);
goto exit;
}
code = (PyCodeObject *)args[0];
if (!PyUnicode_Check(args[1])) {
_PyArg_BadArgument("_fix_co_filename", 2, "str", args[1]);
goto exit;
}
if (PyUnicode_READY(args[1]) == -1) {
goto exit;
}
path = args[1];
return_value = _imp__fix_co_filename_impl(module, code, path);
exit:
@ -144,7 +156,7 @@ _imp_init_frozen(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("init_frozen", "str", arg);
_PyArg_BadArgument("init_frozen", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -176,7 +188,7 @@ _imp_get_frozen_object(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("get_frozen_object", "str", arg);
_PyArg_BadArgument("get_frozen_object", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -208,7 +220,7 @@ _imp_is_frozen_package(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_frozen_package", "str", arg);
_PyArg_BadArgument("is_frozen_package", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -240,7 +252,7 @@ _imp_is_builtin(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_builtin", "str", arg);
_PyArg_BadArgument("is_builtin", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -272,7 +284,7 @@ _imp_is_frozen(PyObject *module, PyObject *arg)
PyObject *name;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_frozen", "str", arg);
_PyArg_BadArgument("is_frozen", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -421,4 +433,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=d8be58c9541122f1 input=a9049054013a1b77]*/
/*[clinic end generated code: output=22062cee6e8ba7f3 input=a9049054013a1b77]*/

View File

@ -34,10 +34,24 @@ marshal_dump(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *file;
int version = Py_MARSHAL_VERSION;
if (!_PyArg_ParseStack(args, nargs, "OO|i:dump",
&value, &file, &version)) {
if (!_PyArg_CheckPositional("dump", nargs, 2, 3)) {
goto exit;
}
value = args[0];
file = args[1];
if (nargs < 3) {
goto skip_optional;
}
if (PyFloat_Check(args[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
version = _PyLong_AsInt(args[2]);
if (version == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = marshal_dump_impl(module, value, file, version);
exit:
@ -90,10 +104,23 @@ marshal_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *value;
int version = Py_MARSHAL_VERSION;
if (!_PyArg_ParseStack(args, nargs, "O|i:dumps",
&value, &version)) {
if (!_PyArg_CheckPositional("dumps", nargs, 1, 2)) {
goto exit;
}
value = args[0];
if (nargs < 2) {
goto skip_optional;
}
if (PyFloat_Check(args[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
version = _PyLong_AsInt(args[1]);
if (version == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = marshal_dumps_impl(module, value, version);
exit:
@ -125,7 +152,7 @@ marshal_loads(PyObject *module, PyObject *arg)
goto exit;
}
if (!PyBuffer_IsContiguous(&bytes, 'C')) {
_PyArg_BadArgument("loads", "contiguous buffer", arg);
_PyArg_BadArgument("loads", 0, "contiguous buffer", arg);
goto exit;
}
return_value = marshal_loads_impl(module, &bytes);
@ -138,4 +165,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=8262e7e6c8cbc1ef input=a9049054013a1b77]*/
/*[clinic end generated code: output=ae2bca1aa239e095 input=a9049054013a1b77]*/

View File

@ -175,7 +175,7 @@ sys_intern(PyObject *module, PyObject *arg)
PyObject *s;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("intern", "str", arg);
_PyArg_BadArgument("intern", 0, "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
@ -819,10 +819,22 @@ sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
int depth = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:_getframe",
&depth)) {
if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
depth = _PyLong_AsInt(args[0]);
if (depth == -1 && PyErr_Occurred()) {
goto exit;
}
skip_optional:
return_value = sys__getframe_impl(module, depth);
exit:
@ -872,10 +884,15 @@ sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *func;
PyObject *funcargs;
if (!_PyArg_ParseStack(args, nargs, "OO!:call_tracing",
&func, &PyTuple_Type, &funcargs)) {
if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
goto exit;
}
func = args[0];
if (!PyTuple_Check(args[1])) {
_PyArg_BadArgument("call_tracing", 2, "tuple", args[1]);
goto exit;
}
funcargs = args[1];
return_value = sys_call_tracing_impl(module, func, funcargs);
exit:
@ -1029,4 +1046,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
/*[clinic end generated code: output=0e662f2e19293d57 input=a9049054013a1b77]*/
/*[clinic end generated code: output=6a5202e5bfe5e6bd input=a9049054013a1b77]*/

View File

@ -613,11 +613,21 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Format an error message generated by convertsimple(). */
void
_PyArg_BadArgument(const char *fname, const char *expected, PyObject *arg)
_PyArg_BadArgument(const char *fname, int iarg,
const char *expected, PyObject *arg)
{
PyErr_Format(PyExc_TypeError, "%.200s() argument must be %.50s, not %.50s",
fname, expected,
arg == Py_None ? "None" : arg->ob_type->tp_name);
if (iarg) {
PyErr_Format(PyExc_TypeError,
"%.200s() argument %d must be %.50s, not %.50s",
fname, iarg, expected,
arg == Py_None ? "None" : arg->ob_type->tp_name);
}
else {
PyErr_Format(PyExc_TypeError,
"%.200s() argument must be %.50s, not %.50s",
fname, expected,
arg == Py_None ? "None" : arg->ob_type->tp_name);
}
}
static const char *
@ -2416,13 +2426,12 @@ err:
}
static int
unpack_stack(PyObject *const *args, Py_ssize_t nargs, const char *name,
Py_ssize_t min, Py_ssize_t max, va_list vargs)
{
Py_ssize_t i;
PyObject **o;
#undef _PyArg_CheckPositional
int
_PyArg_CheckPositional(const char *name, Py_ssize_t nargs,
Py_ssize_t min, Py_ssize_t max)
{
assert(min >= 0);
assert(min <= max);
@ -2460,6 +2469,20 @@ unpack_stack(PyObject *const *args, Py_ssize_t nargs, const char *name,
return 0;
}
return 1;
}
static int
unpack_stack(PyObject *const *args, Py_ssize_t nargs, const char *name,
Py_ssize_t min, Py_ssize_t max, va_list vargs)
{
Py_ssize_t i;
PyObject **o;
if (!_PyArg_CheckPositional(name, nargs, min, max)) {
return 0;
}
for (i = 0; i < nargs; i++) {
o = va_arg(vargs, PyObject **);
*o = args[i];

View File

@ -807,8 +807,13 @@ class CLanguage(Language):
{c_basename}({self_type}{self_name}, PyObject *%s)
""" % argname)
parsearg = converters[0].parse_arg(argname)
assert parsearg is not None
parsearg = converters[0].parse_arg(argname, 0)
if parsearg is None:
parsearg = """
if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{
goto exit;
}}
""" % argname
parser_definition = parser_body(parser_prototype,
normalize_snippet(parsearg, indent=4))
@ -857,26 +862,58 @@ class CLanguage(Language):
flags = "METH_FASTCALL"
parser_prototype = parser_prototype_fastcall
parser_definition = parser_body(parser_prototype, normalize_snippet("""
if (!_PyArg_ParseStack(args, nargs, "{format_units}:{name}",
{parse_arguments})) {{
goto exit;
}}
""", indent=4))
nargs = 'nargs'
argname_fmt = 'args[%d]'
else:
# positional-only, but no option groups
# we only need one call to PyArg_ParseTuple
flags = "METH_VARARGS"
parser_prototype = parser_prototype_varargs
nargs = 'PyTuple_GET_SIZE(args)'
argname_fmt = 'PyTuple_GET_ITEM(args, %d)'
parser_definition = parser_body(parser_prototype, normalize_snippet("""
if (!PyArg_ParseTuple(args, "{format_units}:{name}",
{parse_arguments})) {{
parser_code = []
has_optional = False
for i, converter in enumerate(converters):
parsearg = converter.parse_arg(argname_fmt % i, i + 1)
if parsearg is None:
#print('Cannot convert %s %r for %s' % (converter.__class__.__name__, converter.format_unit, converter.name), file=sys.stderr)
parser_code = None
break
if has_optional or converter.default is not unspecified:
has_optional = True
parser_code.append(normalize_snippet("""
if (%s < %d) {{
goto skip_optional;
}}
""", indent=4) % (nargs, i + 1))
parser_code.append(normalize_snippet(parsearg, indent=4))
if parser_code is not None:
parser_code.insert(0, normalize_snippet("""
if (!_PyArg_CheckPositional("{name}", %s, {unpack_min}, {unpack_max})) {{
goto exit;
}}
""", indent=4))
""" % nargs, indent=4))
if has_optional:
parser_code.append("skip_optional:")
else:
if not new_or_init:
parser_code = [normalize_snippet("""
if (!_PyArg_ParseStack(args, nargs, "{format_units}:{name}",
{parse_arguments})) {{
goto exit;
}}
""", indent=4)]
else:
parser_code = [normalize_snippet("""
if (!PyArg_ParseTuple(args, "{format_units}:{name}",
{parse_arguments})) {{
goto exit;
}}
""", indent=4)]
parser_definition = parser_body(parser_prototype, *parser_code)
elif not new_or_init:
flags = "METH_FASTCALL|METH_KEYWORDS"
@ -2536,7 +2573,7 @@ class CConverter(metaclass=CConverterAutoRegister):
"""
pass
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'O&':
return """
if (!{converter}({argname}, &{paramname})) {{{{
@ -2550,25 +2587,27 @@ class CConverter(metaclass=CConverterAutoRegister):
typecheck, typename = type_checks[self.subclass_of]
return """
if (!{typecheck}({argname})) {{{{
_PyArg_BadArgument("{{name}}", "{typename}", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "{typename}", {argname});
goto exit;
}}}}
{paramname} = {cast}{argname};
""".format(argname=argname, paramname=self.name,
argnum=argnum,
typecheck=typecheck, typename=typename, cast=cast)
return """
if (!PyObject_TypeCheck({argname}, {subclass_of})) {{{{
_PyArg_BadArgument("{{name}}", ({subclass_of})->tp_name, {argname});
_PyArg_BadArgument("{{name}}", {argnum}, ({subclass_of})->tp_name, {argname});
goto exit;
}}}}
{paramname} = {cast}{argname};
""".format(argname=argname, paramname=self.name,
""".format(argname=argname, paramname=self.name, argnum=argnum,
subclass_of=self.subclass_of, cast=cast)
return """
if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{
goto exit;
}}
""" % argname
if self.format_unit == 'O':
cast = '(%s)' % self.type if self.type != 'PyObject *' else ''
return """
{paramname} = {cast}{argname};
""".format(argname=argname, paramname=self.name, cast=cast)
return None
type_checks = {
'&PyLong_Type': ('PyLong_Check', 'int'),
@ -2598,7 +2637,7 @@ class bool_converter(CConverter):
self.default = bool(self.default)
self.c_default = str(int(self.default))
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'i':
return """
if (PyFloat_Check({argname})) {{{{
@ -2618,7 +2657,7 @@ class bool_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class char_converter(CConverter):
type = 'char'
@ -2635,7 +2674,7 @@ class char_converter(CConverter):
if self.c_default == '"\'"':
self.c_default = r"'\''"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'c':
return """
if (PyBytes_Check({argname}) && PyBytes_GET_SIZE({argname}) == 1) {{{{
@ -2645,11 +2684,11 @@ class char_converter(CConverter):
{paramname} = PyByteArray_AS_STRING({argname})[0];
}}}}
else {{{{
_PyArg_BadArgument("{{name}}", "a byte string of length 1", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "a byte string of length 1", {argname});
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
@add_legacy_c_converter('B', bitwise=True)
@ -2663,7 +2702,7 @@ class unsigned_char_converter(CConverter):
if bitwise:
self.format_unit = 'B'
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'b':
return """
if (PyFloat_Check({argname})) {{{{
@ -2708,7 +2747,7 @@ class unsigned_char_converter(CConverter):
}}}}
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class byte_converter(unsigned_char_converter): pass
@ -2718,7 +2757,7 @@ class short_converter(CConverter):
format_unit = 'h'
c_ignored_default = "0"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'h':
return """
if (PyFloat_Check({argname})) {{{{
@ -2746,7 +2785,7 @@ class short_converter(CConverter):
}}}}
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class unsigned_short_converter(CConverter):
type = 'unsigned short'
@ -2759,6 +2798,21 @@ class unsigned_short_converter(CConverter):
else:
self.converter = '_PyLong_UnsignedShort_Converter'
def parse_arg(self, argname, argnum):
if self.format_unit == 'H':
return """
if (PyFloat_Check({argname})) {{{{
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}}}}
{paramname} = (unsigned short)PyLong_AsUnsignedLongMask({argname});
if ({paramname} == (unsigned short)-1 && PyErr_Occurred()) {{{{
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname, argnum)
@add_legacy_c_converter('C', accept={str})
class int_converter(CConverter):
type = 'int'
@ -2774,7 +2828,7 @@ class int_converter(CConverter):
if type != None:
self.type = type
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'i':
return """
if (PyFloat_Check({argname})) {{{{
@ -2790,19 +2844,19 @@ class int_converter(CConverter):
elif self.format_unit == 'C':
return """
if (!PyUnicode_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "a unicode character", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "a unicode character", {argname});
goto exit;
}}}}
if (PyUnicode_READY({argname})) {{{{
goto exit;
}}}}
if (PyUnicode_GET_LENGTH({argname}) != 1) {{{{
_PyArg_BadArgument("{{name}}", "a unicode character", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "a unicode character", {argname});
goto exit;
}}}}
{paramname} = PyUnicode_READ_CHAR({argname}, 0);
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
class unsigned_int_converter(CConverter):
type = 'unsigned int'
@ -2815,7 +2869,7 @@ class unsigned_int_converter(CConverter):
else:
self.converter = '_PyLong_UnsignedInt_Converter'
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'I':
return """
if (PyFloat_Check({argname})) {{{{
@ -2828,7 +2882,7 @@ class unsigned_int_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class long_converter(CConverter):
type = 'long'
@ -2836,7 +2890,7 @@ class long_converter(CConverter):
format_unit = 'l'
c_ignored_default = "0"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'l':
return """
if (PyFloat_Check({argname})) {{{{
@ -2849,7 +2903,7 @@ class long_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class unsigned_long_converter(CConverter):
type = 'unsigned long'
@ -2862,16 +2916,16 @@ class unsigned_long_converter(CConverter):
else:
self.converter = '_PyLong_UnsignedLong_Converter'
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'k':
return """
if (!PyLong_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "int", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "int", {argname});
goto exit;
}}}}
{paramname} = PyLong_AsUnsignedLongMask({argname});
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
class long_long_converter(CConverter):
type = 'long long'
@ -2879,7 +2933,7 @@ class long_long_converter(CConverter):
format_unit = 'L'
c_ignored_default = "0"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'L':
return """
if (PyFloat_Check({argname})) {{{{
@ -2892,7 +2946,7 @@ class long_long_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class unsigned_long_long_converter(CConverter):
type = 'unsigned long long'
@ -2905,16 +2959,16 @@ class unsigned_long_long_converter(CConverter):
else:
self.converter = '_PyLong_UnsignedLongLong_Converter'
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'K':
return """
if (!PyLong_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "int", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "int", {argname});
goto exit;
}}}}
{paramname} = PyLong_AsUnsignedLongLongMask({argname});
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
class Py_ssize_t_converter(CConverter):
type = 'Py_ssize_t'
@ -2929,7 +2983,7 @@ class Py_ssize_t_converter(CConverter):
else:
fail("Py_ssize_t_converter: illegal 'accept' argument " + repr(accept))
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'n':
return """
if (PyFloat_Check({argname})) {{{{
@ -2950,7 +3004,7 @@ class Py_ssize_t_converter(CConverter):
{paramname} = ival;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class slice_index_converter(CConverter):
@ -2969,7 +3023,7 @@ class size_t_converter(CConverter):
converter = '_PyLong_Size_t_Converter'
c_ignored_default = "0"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'n':
return """
{paramname} = PyNumber_AsSsize_t({argname}, PyExc_OverflowError);
@ -2977,7 +3031,7 @@ class size_t_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class float_converter(CConverter):
@ -2986,7 +3040,7 @@ class float_converter(CConverter):
format_unit = 'f'
c_ignored_default = "0.0"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'f':
return """
{paramname} = (float) PyFloat_AsDouble({argname});
@ -2994,7 +3048,7 @@ class float_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class double_converter(CConverter):
type = 'double'
@ -3002,7 +3056,7 @@ class double_converter(CConverter):
format_unit = 'd'
c_ignored_default = "0.0"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'd':
return """
{paramname} = PyFloat_AsDouble({argname});
@ -3010,7 +3064,7 @@ class double_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class Py_complex_converter(CConverter):
@ -3019,7 +3073,7 @@ class Py_complex_converter(CConverter):
format_unit = 'D'
c_ignored_default = "{0.0, 0.0}"
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'D':
return """
{paramname} = PyComplex_AsCComplex({argname});
@ -3027,7 +3081,7 @@ class Py_complex_converter(CConverter):
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
return super().parse_arg(argname, argnum)
class object_converter(CConverter):
@ -3093,11 +3147,11 @@ class str_converter(CConverter):
name = self.name
return "".join(["if (", name, ") {\n PyMem_FREE(", name, ");\n}\n"])
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 's':
return """
if (!PyUnicode_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "str", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "str", {argname});
goto exit;
}}}}
Py_ssize_t {paramname}_length;
@ -3109,8 +3163,29 @@ class str_converter(CConverter):
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
if self.format_unit == 'z':
return """
if ({argname} == Py_None) {{{{
{paramname} = NULL;
}}}}
else if (PyUnicode_Check({argname})) {{{{
Py_ssize_t {paramname}_length;
{paramname} = PyUnicode_AsUTF8AndSize({argname}, &{paramname}_length);
if ({paramname} == NULL) {{{{
goto exit;
}}}}
if (strlen({paramname}) != (size_t){paramname}_length) {{{{
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}}}}
}}}}
else {{{{
_PyArg_BadArgument("{{name}}", {argnum}, "str or None", {argname});
goto exit;
}}}}
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
#
# This is the fourth or fifth rewrite of registering all the
@ -3165,51 +3240,53 @@ class PyBytesObject_converter(CConverter):
format_unit = 'S'
# accept = {bytes}
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'S':
return """
if (!PyBytes_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "bytes", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "bytes", {argname});
goto exit;
}}}}
{paramname} = ({type}){argname};
""".format(argname=argname, paramname=self.name, type=self.type)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum,
type=self.type)
return super().parse_arg(argname, argnum)
class PyByteArrayObject_converter(CConverter):
type = 'PyByteArrayObject *'
format_unit = 'Y'
# accept = {bytearray}
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'Y':
return """
if (!PyByteArray_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "bytearray", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "bytearray", {argname});
goto exit;
}}}}
{paramname} = ({type}){argname};
""".format(argname=argname, paramname=self.name, type=self.type)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum,
type=self.type)
return super().parse_arg(argname, argnum)
class unicode_converter(CConverter):
type = 'PyObject *'
default_type = (str, Null, NoneType)
format_unit = 'U'
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'U':
return """
if (!PyUnicode_Check({argname})) {{{{
_PyArg_BadArgument("{{name}}", "str", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "str", {argname});
goto exit;
}}}}
if (PyUnicode_READY({argname}) == -1) {{{{
goto exit;
}}}}
{paramname} = {argname};
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
@add_legacy_c_converter('u#', zeroes=True)
@add_legacy_c_converter('Z', accept={str, NoneType})
@ -3258,17 +3335,17 @@ class Py_buffer_converter(CConverter):
name = self.name
return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
def parse_arg(self, argname):
def parse_arg(self, argname, argnum):
if self.format_unit == 'y*':
return """
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
goto exit;
}}}}
if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
_PyArg_BadArgument("{{name}}", "contiguous buffer", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "contiguous buffer", {argname});
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
""".format(argname=argname, paramname=self.name, argnum=argnum)
elif self.format_unit == 's*':
return """
if (PyUnicode_Check({argname})) {{{{
@ -3284,24 +3361,24 @@ class Py_buffer_converter(CConverter):
goto exit;
}}}}
if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
_PyArg_BadArgument("{{name}}", "contiguous buffer", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "contiguous buffer", {argname});
goto exit;
}}}}
}}}}
""".format(argname=argname, paramname=self.name)
""".format(argname=argname, paramname=self.name, argnum=argnum)
elif self.format_unit == 'w*':
return """
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_WRITABLE) < 0) {{{{
PyErr_Clear();
_PyArg_BadArgument("{{name}}", "read-write bytes-like object", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "read-write bytes-like object", {argname});
goto exit;
}}}}
if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
_PyArg_BadArgument("{{name}}", "contiguous buffer", {argname});
_PyArg_BadArgument("{{name}}", {argnum}, "contiguous buffer", {argname});
goto exit;
}}}}
""".format(argname=argname, paramname=self.name)
return super().parse_arg(argname)
""".format(argname=argname, paramname=self.name, argnum=argnum)
return super().parse_arg(argname, argnum)
def correct_name_for_self(f):