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) \ #define _PyArg_NoPositional(funcname, args) \
((args) == NULL || _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 #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) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg); _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer); 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) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto1", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "contiguous buffer", arg); _PyArg_BadArgument("readinto1", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer); 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; PyObject *return_value = NULL;
Py_ssize_t size = 0; Py_ssize_t size = 0;
if (!_PyArg_ParseStack(args, nargs, "|n:peek", if (!_PyArg_CheckPositional("peek", nargs, 0, 1)) {
&size)) {
goto exit; 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); return_value = _io__Buffered_peek_impl(self, size);
exit: exit:
@ -141,10 +161,16 @@ _io__Buffered_read(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t n = -1; Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &n)) {
goto exit; 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); return_value = _io__Buffered_read_impl(self, n);
exit: exit:
@ -168,10 +194,30 @@ _io__Buffered_read1(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t n = -1; Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:read1", if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
&n)) {
goto exit; 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); return_value = _io__Buffered_read1_impl(self, n);
exit: exit:
@ -197,11 +243,11 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg); _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io__Buffered_readinto_impl(self, &buffer); 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) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto1", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "contiguous buffer", arg); _PyArg_BadArgument("readinto1", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io__Buffered_readinto1_impl(self, &buffer); 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; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readline", if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io__Buffered_readline_impl(self, size);
exit: exit:
@ -297,10 +349,23 @@ _io__Buffered_seek(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *targetobj; PyObject *targetobj;
int whence = 0; int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:seek", if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
&targetobj, &whence)) {
goto exit; 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); return_value = _io__Buffered_seek_impl(self, targetobj, whence);
exit: exit:
@ -418,7 +483,7 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg); _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io_BufferedWriter_write_impl(self, &buffer); 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)) { !_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
goto exit; goto exit;
} }
if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair", if (!_PyArg_CheckPositional("BufferedRWPair", PyTuple_GET_SIZE(args), 2, 3)) {
&reader, &writer, &buffer_size)) {
goto exit; 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); return_value = _io_BufferedRWPair___init___impl((rwpair *)self, reader, writer, buffer_size);
exit: exit:
@ -504,4 +591,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit: exit:
return return_value; 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; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_BytesIO_read_impl(self, size);
exit: exit:
@ -200,10 +206,16 @@ _io_BytesIO_read1(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read1", if (!_PyArg_CheckPositional("read1", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_BytesIO_read1_impl(self, size);
exit: exit:
@ -232,10 +244,16 @@ _io_BytesIO_readline(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readline", if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_BytesIO_readline_impl(self, size);
exit: exit:
@ -298,11 +316,11 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg); _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io_BytesIO_readinto_impl(self, &buffer); 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; PyObject *return_value = NULL;
Py_ssize_t size = self->pos; Py_ssize_t size = self->pos;
if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_BytesIO_truncate_impl(self, size);
exit: exit:
@ -372,10 +396,39 @@ _io_BytesIO_seek(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t pos; Py_ssize_t pos;
int whence = 0; int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "n|i:seek", if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
&pos, &whence)) {
goto exit; 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); return_value = _io_BytesIO_seek_impl(self, pos, whence);
exit: exit:
@ -450,4 +503,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit: exit:
return return_value; 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) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg); _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io_FileIO_readinto_impl(self, &buffer); 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; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_FileIO_read_impl(self, size);
exit: exit:
@ -255,7 +261,7 @@ _io_FileIO_write(fileio *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&b, 'C')) { if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg); _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io_FileIO_write_impl(self, &b); 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; PyObject *pos;
int whence = 0; int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:seek", if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
&pos, &whence)) {
goto exit; 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); return_value = _io_FileIO_seek_impl(self, pos, whence);
exit: exit:
@ -383,4 +402,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF #ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_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; PyObject *return_value = NULL;
Py_ssize_t limit = -1; Py_ssize_t limit = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readline", if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &limit)) {
goto exit; 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); return_value = _io__IOBase_readline_impl(self, limit);
exit: exit:
@ -217,10 +223,16 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t hint = -1; Py_ssize_t hint = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readlines", if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &hint)) {
goto exit; 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); return_value = _io__IOBase_readlines_impl(self, hint);
exit: exit:
@ -252,10 +264,30 @@ _io__RawIOBase_read(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t n = -1; Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
&n)) {
goto exit; 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); return_value = _io__RawIOBase_read_impl(self, n);
exit: exit:
@ -279,4 +311,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{ {
return _io__RawIOBase_readall_impl(self); 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; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_StringIO_read_impl(self, size);
exit: exit:
@ -89,10 +95,16 @@ _io_StringIO_readline(stringio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:readline", if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_StringIO_readline_impl(self, size);
exit: exit:
@ -121,10 +133,16 @@ _io_StringIO_truncate(stringio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t size = self->pos; Py_ssize_t size = self->pos;
if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io_StringIO_truncate_impl(self, size);
exit: exit:
@ -156,10 +174,39 @@ _io_StringIO_seek(stringio *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t pos; Py_ssize_t pos;
int whence = 0; int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "n|i:seek", if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
&pos, &whence)) {
goto exit; 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); return_value = _io_StringIO_seek_impl(self, pos, whence);
exit: exit:
@ -286,4 +333,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{ {
return _io_StringIO_seekable_impl(self); 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; PyObject *text;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("write", "str", arg); _PyArg_BadArgument("write", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { 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; PyObject *return_value = NULL;
Py_ssize_t n = -1; Py_ssize_t n = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &n)) {
goto exit; 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); return_value = _io_TextIOWrapper_read_impl(self, n);
exit: exit:
@ -308,10 +314,30 @@ _io_TextIOWrapper_readline(textio *self, PyObject *const *args, Py_ssize_t nargs
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:readline", if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
&size)) {
goto exit; 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); return_value = _io_TextIOWrapper_readline_impl(self, size);
exit: exit:
@ -336,10 +362,23 @@ _io_TextIOWrapper_seek(textio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *cookieObj; PyObject *cookieObj;
int whence = 0; int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:seek", if (!_PyArg_CheckPositional("seek", nargs, 1, 2)) {
&cookieObj, &whence)) {
goto exit; 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); return_value = _io_TextIOWrapper_seek_impl(self, cookieObj, whence);
exit: exit:
@ -509,4 +548,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{ {
return _io_TextIOWrapper_close_impl(self); 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) { if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear(); PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg); _PyArg_BadArgument("readinto", 0, "read-write bytes-like object", arg);
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg); _PyArg_BadArgument("readinto", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer); 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; PyObject *return_value = NULL;
Py_ssize_t size = -1; Py_ssize_t size = -1;
if (!_PyArg_ParseStack(args, nargs, "|O&:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
_Py_convert_optional_to_ssize_t, &size)) {
goto exit; 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); return_value = _io__WindowsConsoleIO_read_impl(self, size);
exit: exit:
@ -265,7 +271,7 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&b, 'C')) { if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg); _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _io__WindowsConsoleIO_write_impl(self, &b); 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 #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_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; PyLongObject *statelong;
if (!PyLong_Check(arg)) { if (!PyLong_Check(arg)) {
_PyArg_BadArgument("setstate", "int", arg); _PyArg_BadArgument("setstate", 0, "int", arg);
goto exit; goto exit;
} }
statelong = (PyLongObject *)arg; statelong = (PyLongObject *)arg;
@ -251,7 +251,7 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoder
PyObject *state; PyObject *state;
if (!PyTuple_Check(arg)) { if (!PyTuple_Check(arg)) {
_PyArg_BadArgument("setstate", "tuple", arg); _PyArg_BadArgument("setstate", 0, "tuple", arg);
goto exit; goto exit;
} }
state = arg; state = arg;
@ -422,4 +422,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \ #define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__}, {"__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; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg); _PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _bz2_BZ2Compressor_compress_impl(self, &data); 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)) { !_PyArg_NoKeywords("BZ2Compressor", kwargs)) {
goto exit; goto exit;
} }
if (!PyArg_ParseTuple(args, "|i:BZ2Compressor", if (!_PyArg_CheckPositional("BZ2Compressor", PyTuple_GET_SIZE(args), 0, 1)) {
&compresslevel)) {
goto exit; 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); return_value = _bz2_BZ2Compressor___init___impl((BZ2Compressor *)self, compresslevel);
exit: exit:
@ -178,4 +190,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit: exit:
return return_value; 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)) { !_PyArg_NoKeywords("_tuplegetter", kwargs)) {
goto exit; goto exit;
} }
if (!PyArg_ParseTuple(args, "nO:_tuplegetter", if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
&index, &doc)) {
goto exit; 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); return_value = tuplegetter_new_impl(type, index, doc);
exit: exit:
return return_value; 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 *word;
const char *salt; const char *salt;
if (!_PyArg_ParseStack(args, nargs, "ss:crypt", if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) {
&word, &salt)) { 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; goto exit;
} }
return_value = crypt_crypt_impl(module, word, salt); return_value = crypt_crypt_impl(module, word, salt);
@ -35,4 +60,4 @@ crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit: exit:
return return_value; 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 y;
int x; int x;
if (!_PyArg_ParseStack(args, nargs, "ii:move", if (!_PyArg_CheckPositional("move", nargs, 2, 2)) {
&y, &x)) { 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; goto exit;
} }
return_value = _curses_panel_panel_move_impl(self, y, x); return_value = _curses_panel_panel_move_impl(self, y, x);
@ -197,7 +214,7 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg)
PyCursesWindowObject *win; PyCursesWindowObject *win;
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { 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; goto exit;
} }
win = (PyCursesWindowObject *)arg; win = (PyCursesWindowObject *)arg;
@ -271,7 +288,7 @@ _curses_panel_new_panel(PyObject *module, PyObject *arg)
PyCursesWindowObject *win; PyCursesWindowObject *win;
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { 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; goto exit;
} }
win = (PyCursesWindowObject *)arg; win = (PyCursesWindowObject *)arg;
@ -318,4 +335,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
{ {
return _curses_panel_update_panels_impl(module); 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; PyObject *ch;
long attr = A_NORMAL; long attr = A_NORMAL;
if (!_PyArg_ParseStack(args, nargs, "O|l:bkgd", if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) {
&ch, &attr)) {
goto exit; 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); return_value = _curses_window_bkgd_impl(self, ch, attr);
exit: exit:
@ -379,10 +392,23 @@ _curses_window_bkgdset(PyCursesWindowObject *self, PyObject *const *args, Py_ssi
PyObject *ch; PyObject *ch;
long attr = A_NORMAL; long attr = A_NORMAL;
if (!_PyArg_ParseStack(args, nargs, "O|l:bkgdset", if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) {
&ch, &attr)) {
goto exit; 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); return_value = _curses_window_bkgdset_impl(self, ch, attr);
exit: exit:
@ -623,10 +649,23 @@ _curses_window_echochar(PyCursesWindowObject *self, PyObject *const *args, Py_ss
PyObject *ch; PyObject *ch;
long attr = A_NORMAL; long attr = A_NORMAL;
if (!_PyArg_ParseStack(args, nargs, "O|l:echochar", if (!_PyArg_CheckPositional("echochar", nargs, 1, 2)) {
&ch, &attr)) {
goto exit; 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); return_value = _curses_window_echochar_impl(self, ch, attr);
exit: exit:
@ -660,8 +699,25 @@ _curses_window_enclose(PyCursesWindowObject *self, PyObject *const *args, Py_ssi
int x; int x;
long _return_value; long _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:enclose", if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) {
&y, &x)) { 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; goto exit;
} }
_return_value = _curses_window_enclose_impl(self, y, x); _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 beg;
int num; int num;
if (!_PyArg_ParseStack(args, nargs, "ii:redrawln", if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) {
&beg, &num)) { 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; goto exit;
} }
return_value = _curses_window_redrawln_impl(self, beg, num); 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 top;
int bottom; int bottom;
if (!_PyArg_ParseStack(args, nargs, "ii:setscrreg", if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) {
&top, &bottom)) { 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; goto exit;
} }
return_value = _curses_window_setscrreg_impl(self, top, bottom); 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; PyObject *return_value = NULL;
int flag = 1; int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:cbreak", if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) {
&flag)) {
goto exit; 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); return_value = _curses_cbreak_impl(module, flag);
exit: exit:
@ -2158,10 +2260,22 @@ _curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
int flag = 1; int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:echo", if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) {
&flag)) {
goto exit; 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); return_value = _curses_echo_impl(module, flag);
exit: exit:
@ -2321,10 +2435,65 @@ _curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int z; int z;
unsigned long bstate; unsigned long bstate;
if (!_PyArg_ParseStack(args, nargs, "hiiik:ungetmouse", if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) {
&id, &x, &y, &z, &bstate)) {
goto exit; 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); return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate);
exit: exit:
@ -2527,10 +2696,105 @@ _curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
short g; short g;
short b; short b;
if (!_PyArg_ParseStack(args, nargs, "hhhh:init_color", if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) {
&color_number, &r, &g, &b)) {
goto exit; 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); return_value = _curses_init_color_impl(module, color_number, r, g, b);
exit: exit:
@ -2568,10 +2832,81 @@ _curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
short fg; short fg;
short bg; short bg;
if (!_PyArg_ParseStack(args, nargs, "hhh:init_pair", if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) {
&pair_number, &fg, &bg)) {
goto exit; 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); return_value = _curses_init_pair_impl(module, pair_number, fg, bg);
exit: exit:
@ -2712,8 +3047,25 @@ _curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t narg
int nlines; int nlines;
int ncols; int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:is_term_resized", if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) {
&nlines, &ncols)) { 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; goto exit;
} }
return_value = _curses_is_term_resized_impl(module, nlines, ncols); return_value = _curses_is_term_resized_impl(module, nlines, ncols);
@ -2905,7 +3257,7 @@ _curses_mousemask(PyObject *module, PyObject *arg)
unsigned long newmask; unsigned long newmask;
if (!PyLong_Check(arg)) { if (!PyLong_Check(arg)) {
_PyArg_BadArgument("mousemask", "int", arg); _PyArg_BadArgument("mousemask", 0, "int", arg);
goto exit; goto exit;
} }
newmask = PyLong_AsUnsignedLongMask(arg); newmask = PyLong_AsUnsignedLongMask(arg);
@ -2977,8 +3329,25 @@ _curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines; int nlines;
int ncols; int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:newpad", if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) {
&nlines, &ncols)) { 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; goto exit;
} }
return_value = _curses_newpad_impl(module, nlines, ncols); 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; PyObject *return_value = NULL;
int flag = 1; int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:nl", if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) {
&flag)) {
goto exit; 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); return_value = _curses_nl_impl(module, flag);
exit: exit:
@ -3317,10 +3698,22 @@ _curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
int flag = 1; int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:qiflush", if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) {
&flag)) {
goto exit; 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); return_value = _curses_qiflush_impl(module, flag);
exit: exit:
@ -3383,10 +3776,22 @@ _curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
int flag = 1; int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:raw", if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) {
&flag)) {
goto exit; 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); return_value = _curses_raw_impl(module, flag);
exit: exit:
@ -3476,8 +3881,25 @@ _curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int nlines; int nlines;
int ncols; int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:resizeterm", if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) {
&nlines, &ncols)) { 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; goto exit;
} }
return_value = _curses_resizeterm_impl(module, nlines, ncols); 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 nlines;
int ncols; int ncols;
if (!_PyArg_ParseStack(args, nargs, "ii:resize_term", if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) {
&nlines, &ncols)) { 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; goto exit;
} }
return_value = _curses_resize_term_impl(module, nlines, ncols); 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 y;
int x; int x;
if (!_PyArg_ParseStack(args, nargs, "ii:setsyx", if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) {
&y, &x)) { 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; goto exit;
} }
return_value = _curses_setsyx_impl(module, y, x); return_value = _curses_setsyx_impl(module, y, x);
@ -3676,7 +4132,7 @@ _curses_tigetflag(PyObject *module, PyObject *arg)
const char *capname; const char *capname;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetflag", "str", arg); _PyArg_BadArgument("tigetflag", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t capname_length; Py_ssize_t capname_length;
@ -3719,7 +4175,7 @@ _curses_tigetnum(PyObject *module, PyObject *arg)
const char *capname; const char *capname;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetnum", "str", arg); _PyArg_BadArgument("tigetnum", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t capname_length; Py_ssize_t capname_length;
@ -3762,7 +4218,7 @@ _curses_tigetstr(PyObject *module, PyObject *arg)
const char *capname; const char *capname;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetstr", "str", arg); _PyArg_BadArgument("tigetstr", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t capname_length; 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 #ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF #define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_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"; const char *flags = "r";
int mode = 438; int mode = 438;
if (!_PyArg_ParseStack(args, nargs, "U|si:open", if (!_PyArg_CheckPositional("open", nargs, 1, 3)) {
&filename, &flags, &mode)) {
goto exit; 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); return_value = dbmopen_impl(module, filename, flags, mode);
exit: exit:
return return_value; 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; PyObject *subelement;
if (!PyObject_TypeCheck(arg, &Element_Type)) { 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; goto exit;
} }
subelement = arg; subelement = arg;
@ -82,7 +82,7 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg)
PyObject *memo; PyObject *memo;
if (!PyDict_Check(arg)) { if (!PyDict_Check(arg)) {
_PyArg_BadArgument("__deepcopy__", "dict", arg); _PyArg_BadArgument("__deepcopy__", 0, "dict", arg);
goto exit; goto exit;
} }
memo = arg; memo = arg;
@ -420,10 +420,31 @@ _elementtree_Element_insert(ElementObject *self, PyObject *const *args, Py_ssize
Py_ssize_t index; Py_ssize_t index;
PyObject *subelement; PyObject *subelement;
if (!_PyArg_ParseStack(args, nargs, "nO!:insert", if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
&index, &Element_Type, &subelement)) {
goto exit; 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); return_value = _elementtree_Element_insert_impl(self, index, subelement);
exit: exit:
@ -512,7 +533,7 @@ _elementtree_Element_remove(ElementObject *self, PyObject *arg)
PyObject *subelement; PyObject *subelement;
if (!PyObject_TypeCheck(arg, &Element_Type)) { 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; goto exit;
} }
subelement = arg; subelement = arg;
@ -723,4 +744,4 @@ _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args,
exit: exit:
return return_value; 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"; const char *flags = "r";
int mode = 438; int mode = 438;
if (!_PyArg_ParseStack(args, nargs, "U|si:open", if (!_PyArg_CheckPositional("open", nargs, 1, 3)) {
&filename, &flags, &mode)) {
goto exit; 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); return_value = dbmopen_impl(module, filename, flags, mode);
exit: exit:
return return_value; 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; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg); _PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _lzma_LZMACompressor_compress_impl(self, &data); 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; lzma_vli filter_id;
Py_buffer encoded_props = {NULL, NULL}; Py_buffer encoded_props = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "O&y*:_decode_filter_properties", if (!_PyArg_CheckPositional("_decode_filter_properties", nargs, 2, 2)) {
lzma_vli_converter, &filter_id, &encoded_props)) { 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; goto exit;
} }
return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props); return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props);
@ -266,4 +275,4 @@ exit:
return return_value; 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 default_value = 0;
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "O|n:length_hint", if (!_PyArg_CheckPositional("length_hint", nargs, 1, 2)) {
&obj, &default_value)) {
goto exit; 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); _return_value = _operator_length_hint_impl(module, obj, default_value);
if ((_return_value == -1) && PyErr_Occurred()) { if ((_return_value == -1) && PyErr_Occurred()) {
goto exit; goto exit;
@ -1469,4 +1490,4 @@ _operator__compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t na
exit: exit:
return return_value; 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; PyObject *return_value = NULL;
int binary_mode = 0; int binary_mode = 0;
if (!_PyArg_ParseStack(args, nargs, "|p:getpeercert", if (!_PyArg_CheckPositional("getpeercert", nargs, 0, 1)) {
&binary_mode)) {
goto exit; 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); return_value = _ssl__SSLSocket_getpeercert_impl(self, binary_mode);
exit: exit:
@ -215,7 +222,7 @@ _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&b, 'C')) { if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg); _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _ssl__SSLSocket_write_impl(self, &b); return_value = _ssl__SSLSocket_write_impl(self, &b);
@ -377,8 +384,16 @@ _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("_SSLContext", kwargs)) { !_PyArg_NoKeywords("_SSLContext", kwargs)) {
goto exit; goto exit;
} }
if (!PyArg_ParseTuple(args, "i:_SSLContext", if (!_PyArg_CheckPositional("_SSLContext", PyTuple_GET_SIZE(args), 1, 1)) {
&proto_version)) { 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; goto exit;
} }
return_value = _ssl__SSLContext_impl(type, proto_version); return_value = _ssl__SSLContext_impl(type, proto_version);
@ -405,7 +420,7 @@ _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
const char *cipherlist; const char *cipherlist;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("set_ciphers", "str", arg); _PyArg_BadArgument("set_ciphers", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t cipherlist_length; Py_ssize_t cipherlist_length;
@ -466,7 +481,7 @@ _ssl__SSLContext__set_npn_protocols(PySSLContext *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&protos, 'C')) { if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_npn_protocols", "contiguous buffer", arg); _PyArg_BadArgument("_set_npn_protocols", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos); 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; goto exit;
} }
if (!PyBuffer_IsContiguous(&protos, 'C')) { if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_alpn_protocols", "contiguous buffer", arg); _PyArg_BadArgument("_set_alpn_protocols", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos); 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; PyObject *return_value = NULL;
int len = -1; int len = -1;
if (!_PyArg_ParseStack(args, nargs, "|i:read", if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
&len)) {
goto exit; 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); return_value = _ssl_MemoryBIO_read_impl(self, len);
exit: exit:
@ -849,7 +876,7 @@ _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&b, 'C')) { if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg); _PyArg_BadArgument("write", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = _ssl_MemoryBIO_write_impl(self, &b); 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}; Py_buffer view = {NULL, NULL};
double entropy; double entropy;
if (!_PyArg_ParseStack(args, nargs, "s*d:RAND_add", if (!_PyArg_CheckPositional("RAND_add", nargs, 2, 2)) {
&view, &entropy)) { 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; goto exit;
} }
return_value = _ssl_RAND_add_impl(module, &view, entropy); return_value = _ssl_RAND_add_impl(module, &view, entropy);
@ -1237,4 +1284,4 @@ exit:
#ifndef _SSL_ENUM_CRLS_METHODDEF #ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_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; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack", "contiguous buffer", arg); _PyArg_BadArgument("unpack", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = Struct_unpack_impl(self, &buffer); 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; PyStructObject *s_object = NULL;
Py_buffer buffer = {NULL, NULL}; Py_buffer buffer = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "O&y*:unpack", if (!_PyArg_CheckPositional("unpack", nargs, 2, 2)) {
cache_struct_converter, &s_object, &buffer)) { 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; goto exit;
} }
return_value = unpack_impl(module, s_object, &buffer); 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; PyStructObject *s_object = NULL;
PyObject *buffer; PyObject *buffer;
if (!_PyArg_ParseStack(args, nargs, "O&O:iter_unpack", if (!_PyArg_CheckPositional("iter_unpack", nargs, 2, 2)) {
cache_struct_converter, &s_object, &buffer)) {
goto exit; goto exit;
} }
if (!cache_struct_converter(args[0], &s_object)) {
goto exit;
}
buffer = args[1];
return_value = iter_unpack_impl(module, s_object, buffer); return_value = iter_unpack_impl(module, s_object, buffer);
exit: exit:
@ -307,4 +319,4 @@ exit:
return return_value; 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; const char *script;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("eval", "str", arg); _PyArg_BadArgument("eval", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t script_length; Py_ssize_t script_length;
@ -56,7 +56,7 @@ _tkinter_tkapp_evalfile(TkappObject *self, PyObject *arg)
const char *fileName; const char *fileName;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("evalfile", "str", arg); _PyArg_BadArgument("evalfile", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t fileName_length; Py_ssize_t fileName_length;
@ -92,7 +92,7 @@ _tkinter_tkapp_record(TkappObject *self, PyObject *arg)
const char *script; const char *script;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("record", "str", arg); _PyArg_BadArgument("record", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t script_length; Py_ssize_t script_length;
@ -128,7 +128,7 @@ _tkinter_tkapp_adderrorinfo(TkappObject *self, PyObject *arg)
const char *msg; const char *msg;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("adderrorinfo", "str", arg); _PyArg_BadArgument("adderrorinfo", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t msg_length; Py_ssize_t msg_length;
@ -188,7 +188,7 @@ _tkinter_tkapp_exprstring(TkappObject *self, PyObject *arg)
const char *s; const char *s;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprstring", "str", arg); _PyArg_BadArgument("exprstring", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t s_length; Py_ssize_t s_length;
@ -224,7 +224,7 @@ _tkinter_tkapp_exprlong(TkappObject *self, PyObject *arg)
const char *s; const char *s;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprlong", "str", arg); _PyArg_BadArgument("exprlong", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t s_length; Py_ssize_t s_length;
@ -260,7 +260,7 @@ _tkinter_tkapp_exprdouble(TkappObject *self, PyObject *arg)
const char *s; const char *s;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprdouble", "str", arg); _PyArg_BadArgument("exprdouble", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t s_length; Py_ssize_t s_length;
@ -296,7 +296,7 @@ _tkinter_tkapp_exprboolean(TkappObject *self, PyObject *arg)
const char *s; const char *s;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprboolean", "str", arg); _PyArg_BadArgument("exprboolean", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t s_length; Py_ssize_t s_length;
@ -349,10 +349,23 @@ _tkinter_tkapp_createcommand(TkappObject *self, PyObject *const *args, Py_ssize_
const char *name; const char *name;
PyObject *func; PyObject *func;
if (!_PyArg_ParseStack(args, nargs, "sO:createcommand", if (!_PyArg_CheckPositional("createcommand", nargs, 2, 2)) {
&name, &func)) {
goto exit; 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); return_value = _tkinter_tkapp_createcommand_impl(self, name, func);
exit: exit:
@ -377,7 +390,7 @@ _tkinter_tkapp_deletecommand(TkappObject *self, PyObject *arg)
const char *name; const char *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("deletecommand", "str", arg); _PyArg_BadArgument("deletecommand", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t name_length; Py_ssize_t name_length;
@ -417,10 +430,20 @@ _tkinter_tkapp_createfilehandler(TkappObject *self, PyObject *const *args, Py_ss
int mask; int mask;
PyObject *func; PyObject *func;
if (!_PyArg_ParseStack(args, nargs, "OiO:createfilehandler", if (!_PyArg_CheckPositional("createfilehandler", nargs, 3, 3)) {
&file, &mask, &func)) {
goto exit; 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); return_value = _tkinter_tkapp_createfilehandler_impl(self, file, mask, func);
exit: exit:
@ -477,10 +500,19 @@ _tkinter_tkapp_createtimerhandler(TkappObject *self, PyObject *const *args, Py_s
int milliseconds; int milliseconds;
PyObject *func; PyObject *func;
if (!_PyArg_ParseStack(args, nargs, "iO:createtimerhandler", if (!_PyArg_CheckPositional("createtimerhandler", nargs, 2, 2)) {
&milliseconds, &func)) {
goto exit; 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); return_value = _tkinter_tkapp_createtimerhandler_impl(self, milliseconds, func);
exit: exit:
@ -504,10 +536,22 @@ _tkinter_tkapp_mainloop(TkappObject *self, PyObject *const *args, Py_ssize_t nar
PyObject *return_value = NULL; PyObject *return_value = NULL;
int threshold = 0; int threshold = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:mainloop", if (!_PyArg_CheckPositional("mainloop", nargs, 0, 1)) {
&threshold)) {
goto exit; 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); return_value = _tkinter_tkapp_mainloop_impl(self, threshold);
exit: exit:
@ -531,10 +575,22 @@ _tkinter_tkapp_dooneevent(TkappObject *self, PyObject *const *args, Py_ssize_t n
PyObject *return_value = NULL; PyObject *return_value = NULL;
int flags = 0; int flags = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:dooneevent", if (!_PyArg_CheckPositional("dooneevent", nargs, 0, 1)) {
&flags)) {
goto exit; 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); return_value = _tkinter_tkapp_dooneevent_impl(self, flags);
exit: exit:
@ -654,10 +710,132 @@ _tkinter_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int sync = 0; int sync = 0;
const char *use = NULL; const char *use = NULL;
if (!_PyArg_ParseStack(args, nargs, "|zssiiiiz:create", if (!_PyArg_CheckPositional("create", nargs, 0, 8)) {
&screenName, &baseName, &className, &interactive, &wantobjects, &wantTk, &sync, &use)) {
goto exit; 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); return_value = _tkinter_create_impl(module, screenName, baseName, className, interactive, wantobjects, wantTk, sync, use);
exit: exit:
@ -734,4 +912,4 @@ exit:
#ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF #define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#endif /* !defined(_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; PyObject *return_value = NULL;
int nframe = 1; int nframe = 1;
if (!_PyArg_ParseStack(args, nargs, "|i:start", if (!_PyArg_CheckPositional("start", nargs, 0, 1)) {
&nframe)) {
goto exit; 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); return_value = _tracemalloc_start_impl(module, nframe);
exit: exit:
@ -185,4 +197,4 @@ _tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
{ {
return _tracemalloc_get_traced_memory_impl(module); 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 *dct;
PyObject *key; PyObject *key;
if (!_PyArg_ParseStack(args, nargs, "O!O:_remove_dead_weakref", if (!_PyArg_CheckPositional("_remove_dead_weakref", nargs, 2, 2)) {
&PyDict_Type, &dct, &key)) {
goto exit; 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); return_value = _weakref__remove_dead_weakref_impl(module, dct, key);
exit: exit:
return return_value; 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; PyObject *return_value = NULL;
Py_ssize_t i = -1; Py_ssize_t i = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:pop", if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
&i)) {
goto exit; 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); return_value = array_array_pop_impl(self, i);
exit: exit:
@ -114,10 +134,27 @@ array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t i; Py_ssize_t i;
PyObject *v; PyObject *v;
if (!_PyArg_ParseStack(args, nargs, "nO:insert", if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
&i, &v)) {
goto exit; 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); return_value = array_array_insert_impl(self, i, v);
exit: exit:
@ -212,10 +249,27 @@ array_array_fromfile(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *f; PyObject *f;
Py_ssize_t n; Py_ssize_t n;
if (!_PyArg_ParseStack(args, nargs, "On:fromfile", if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) {
&f, &n)) {
goto exit; 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); return_value = array_array_fromfile_impl(self, f, n);
exit: exit:
@ -291,7 +345,7 @@ array_array_fromstring(arrayobject *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("fromstring", "contiguous buffer", arg); _PyArg_BadArgument("fromstring", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
} }
@ -328,7 +382,7 @@ array_array_frombytes(arrayobject *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&buffer, 'C')) { if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("frombytes", "contiguous buffer", arg); _PyArg_BadArgument("frombytes", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = array_array_frombytes_impl(self, &buffer); 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; enum machine_format_code mformat_code;
PyObject *items; PyObject *items;
if (!_PyArg_ParseStack(args, nargs, "OCiO:_array_reconstructor", if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) {
&arraytype, &typecode, &mformat_code, &items)) {
goto exit; 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); return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
exit: exit:
@ -523,4 +599,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \ #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__}, {"__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; int width;
Py_ssize_t index; Py_ssize_t index;
if (!_PyArg_ParseStack(args, nargs, "y*in:getsample", if (!_PyArg_CheckPositional("getsample", nargs, 3, 3)) {
&fragment, &width, &index)) {
goto exit; 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); return_value = audioop_getsample_impl(module, &fragment, width, index);
exit: exit:
@ -57,8 +89,23 @@ audioop_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:max", if (!_PyArg_CheckPositional("max", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_max_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:minmax", if (!_PyArg_CheckPositional("minmax", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_minmax_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:avg", if (!_PyArg_CheckPositional("avg", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_avg_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:rms", if (!_PyArg_CheckPositional("rms", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_rms_impl(module, &fragment, width); 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 fragment = {NULL, NULL};
Py_buffer reference = {NULL, NULL}; Py_buffer reference = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:findfit", if (!_PyArg_CheckPositional("findfit", nargs, 2, 2)) {
&fragment, &reference)) { 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; goto exit;
} }
return_value = audioop_findfit_impl(module, &fragment, &reference); 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 fragment = {NULL, NULL};
Py_buffer reference = {NULL, NULL}; Py_buffer reference = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:findfactor", if (!_PyArg_CheckPositional("findfactor", nargs, 2, 2)) {
&fragment, &reference)) { 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; goto exit;
} }
return_value = audioop_findfactor_impl(module, &fragment, &reference); 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_buffer fragment = {NULL, NULL};
Py_ssize_t length; Py_ssize_t length;
if (!_PyArg_ParseStack(args, nargs, "y*n:findmax", if (!_PyArg_CheckPositional("findmax", nargs, 2, 2)) {
&fragment, &length)) {
goto exit; 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); return_value = audioop_findmax_impl(module, &fragment, length);
exit: exit:
@ -306,8 +447,23 @@ audioop_avgpp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:avgpp", if (!_PyArg_CheckPositional("avgpp", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_avgpp_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:maxpp", if (!_PyArg_CheckPositional("maxpp", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_maxpp_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:cross", if (!_PyArg_CheckPositional("cross", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_cross_impl(module, &fragment, width); 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; int width;
double factor; double factor;
if (!_PyArg_ParseStack(args, nargs, "y*id:mul", if (!_PyArg_CheckPositional("mul", nargs, 3, 3)) {
&fragment, &width, &factor)) { 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; goto exit;
} }
return_value = audioop_mul_impl(module, &fragment, width, factor); 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 lfactor;
double rfactor; double rfactor;
if (!_PyArg_ParseStack(args, nargs, "y*idd:tomono", if (!_PyArg_CheckPositional("tomono", nargs, 4, 4)) {
&fragment, &width, &lfactor, &rfactor)) { 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; goto exit;
} }
return_value = audioop_tomono_impl(module, &fragment, width, lfactor, rfactor); 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 lfactor;
double rfactor; double rfactor;
if (!_PyArg_ParseStack(args, nargs, "y*idd:tostereo", if (!_PyArg_CheckPositional("tostereo", nargs, 4, 4)) {
&fragment, &width, &lfactor, &rfactor)) { 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; goto exit;
} }
return_value = audioop_tostereo_impl(module, &fragment, width, lfactor, rfactor); 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}; Py_buffer fragment2 = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*y*i:add", if (!_PyArg_CheckPositional("add", nargs, 3, 3)) {
&fragment1, &fragment2, &width)) { 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; goto exit;
} }
return_value = audioop_add_impl(module, &fragment1, &fragment2, width); 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 width;
int bias; int bias;
if (!_PyArg_ParseStack(args, nargs, "y*ii:bias", if (!_PyArg_CheckPositional("bias", nargs, 3, 3)) {
&fragment, &width, &bias)) { 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; goto exit;
} }
return_value = audioop_bias_impl(module, &fragment, width, bias); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:reverse", if (!_PyArg_CheckPositional("reverse", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_reverse_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:byteswap", if (!_PyArg_CheckPositional("byteswap", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_byteswap_impl(module, &fragment, width); 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 width;
int newwidth; int newwidth;
if (!_PyArg_ParseStack(args, nargs, "y*ii:lin2lin", if (!_PyArg_CheckPositional("lin2lin", nargs, 3, 3)) {
&fragment, &width, &newwidth)) { 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; goto exit;
} }
return_value = audioop_lin2lin_impl(module, &fragment, width, newwidth); 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 weightA = 1;
int weightB = 0; int weightB = 0;
if (!_PyArg_ParseStack(args, nargs, "y*iiiiO|ii:ratecv", if (!_PyArg_CheckPositional("ratecv", nargs, 6, 8)) {
&fragment, &width, &nchannels, &inrate, &outrate, &state, &weightA, &weightB)) {
goto exit; 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); return_value = audioop_ratecv_impl(module, &fragment, width, nchannels, inrate, outrate, state, weightA, weightB);
exit: exit:
@ -740,8 +1159,23 @@ audioop_lin2ulaw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer fragment = {NULL, NULL}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:lin2ulaw", if (!_PyArg_CheckPositional("lin2ulaw", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_lin2ulaw_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:ulaw2lin", if (!_PyArg_CheckPositional("ulaw2lin", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_ulaw2lin_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:lin2alaw", if (!_PyArg_CheckPositional("lin2alaw", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_lin2alaw_impl(module, &fragment, width); 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}; Py_buffer fragment = {NULL, NULL};
int width; int width;
if (!_PyArg_ParseStack(args, nargs, "y*i:alaw2lin", if (!_PyArg_CheckPositional("alaw2lin", nargs, 2, 2)) {
&fragment, &width)) { 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; goto exit;
} }
return_value = audioop_alaw2lin_impl(module, &fragment, width); 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; int width;
PyObject *state; PyObject *state;
if (!_PyArg_ParseStack(args, nargs, "y*iO:lin2adpcm", if (!_PyArg_CheckPositional("lin2adpcm", nargs, 3, 3)) {
&fragment, &width, &state)) {
goto exit; 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); return_value = audioop_lin2adpcm_impl(module, &fragment, width, state);
exit: exit:
@ -914,10 +1409,26 @@ audioop_adpcm2lin(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int width; int width;
PyObject *state; PyObject *state;
if (!_PyArg_ParseStack(args, nargs, "y*iO:adpcm2lin", if (!_PyArg_CheckPositional("adpcm2lin", nargs, 3, 3)) {
&fragment, &width, &state)) {
goto exit; 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); return_value = audioop_adpcm2lin_impl(module, &fragment, width, state);
exit: exit:
@ -928,4 +1439,4 @@ exit:
return return_value; 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; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("rlecode_hqx", "contiguous buffer", arg); _PyArg_BadArgument("rlecode_hqx", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = binascii_rlecode_hqx_impl(module, &data); return_value = binascii_rlecode_hqx_impl(module, &data);
@ -225,7 +225,7 @@ binascii_b2a_hqx(PyObject *module, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hqx", "contiguous buffer", arg); _PyArg_BadArgument("b2a_hqx", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = binascii_b2a_hqx_impl(module, &data); return_value = binascii_b2a_hqx_impl(module, &data);
@ -261,7 +261,7 @@ binascii_rledecode_hqx(PyObject *module, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("rledecode_hqx", "contiguous buffer", arg); _PyArg_BadArgument("rledecode_hqx", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = binascii_rledecode_hqx_impl(module, &data); 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 crc;
unsigned int _return_value; unsigned int _return_value;
if (!_PyArg_ParseStack(args, nargs, "y*I:crc_hqx", if (!_PyArg_CheckPositional("crc_hqx", nargs, 2, 2)) {
&data, &crc)) { 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; goto exit;
} }
_return_value = binascii_crc_hqx_impl(module, &data, crc); _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 crc = 0;
unsigned int _return_value; unsigned int _return_value;
if (!_PyArg_ParseStack(args, nargs, "y*|I:crc32", if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) {
&data, &crc)) {
goto exit; 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); _return_value = binascii_crc32_impl(module, &data, crc);
if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) { if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
goto exit; goto exit;
@ -378,7 +412,7 @@ binascii_b2a_hex(PyObject *module, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hex", "contiguous buffer", arg); _PyArg_BadArgument("b2a_hex", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = binascii_b2a_hex_impl(module, &data); return_value = binascii_b2a_hex_impl(module, &data);
@ -416,7 +450,7 @@ binascii_hexlify(PyObject *module, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("hexlify", "contiguous buffer", arg); _PyArg_BadArgument("hexlify", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = binascii_hexlify_impl(module, &data); return_value = binascii_hexlify_impl(module, &data);
@ -574,4 +608,4 @@ exit:
return return_value; 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; Py_complex x;
PyObject *y_obj = NULL; PyObject *y_obj = NULL;
if (!_PyArg_ParseStack(args, nargs, "D|O:log", if (!_PyArg_CheckPositional("log", nargs, 1, 2)) {
&x, &y_obj)) {
goto exit; 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); return_value = cmath_log_impl(module, x, y_obj);
exit: exit:
@ -755,8 +763,15 @@ cmath_rect(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double r; double r;
double phi; double phi;
if (!_PyArg_ParseStack(args, nargs, "dd:rect", if (!_PyArg_CheckPositional("rect", nargs, 2, 2)) {
&r, &phi)) { goto exit;
}
r = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
phi = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit; goto exit;
} }
return_value = cmath_rect_impl(module, r, phi); 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: exit:
return return_value; 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; int code;
PyObject *arg = NULL; PyObject *arg = NULL;
if (!_PyArg_ParseStack(args, nargs, "O&i|O:fcntl", if (!_PyArg_CheckPositional("fcntl", nargs, 2, 3)) {
conv_descriptor, &fd, &code, &arg)) {
goto exit; 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); return_value = fcntl_fcntl_impl(module, fd, code, arg);
exit: exit:
@ -91,10 +107,33 @@ fcntl_ioctl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *ob_arg = NULL; PyObject *ob_arg = NULL;
int mutate_arg = 1; int mutate_arg = 1;
if (!_PyArg_ParseStack(args, nargs, "O&I|Op:ioctl", if (!_PyArg_CheckPositional("ioctl", nargs, 2, 4)) {
conv_descriptor, &fd, &code, &ob_arg, &mutate_arg)) {
goto exit; 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); return_value = fcntl_ioctl_impl(module, fd, code, ob_arg, mutate_arg);
exit: exit:
@ -123,8 +162,19 @@ fcntl_flock(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int fd; int fd;
int code; int code;
if (!_PyArg_ParseStack(args, nargs, "O&i:flock", if (!_PyArg_CheckPositional("flock", nargs, 2, 2)) {
conv_descriptor, &fd, &code)) { 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; goto exit;
} }
return_value = fcntl_flock_impl(module, fd, code); 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; PyObject *startobj = NULL;
int whence = 0; int whence = 0;
if (!_PyArg_ParseStack(args, nargs, "O&i|OOi:lockf", if (!_PyArg_CheckPositional("lockf", nargs, 2, 5)) {
conv_descriptor, &fd, &code, &lenobj, &startobj, &whence)) {
goto exit; 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); return_value = fcntl_lockf_impl(module, fd, code, lenobj, startobj, whence);
exit: exit:
return return_value; 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)) { !_PyArg_NoKeywords("_grouper", kwargs)) {
goto exit; goto exit;
} }
if (!PyArg_ParseTuple(args, "O!O:_grouper", if (!_PyArg_CheckPositional("_grouper", PyTuple_GET_SIZE(args), 2, 2)) {
&groupby_type, &parent, &tgtkey)) {
goto exit; 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); return_value = itertools__grouper_impl(type, parent, tgtkey);
exit: exit:
@ -84,10 +89,16 @@ itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs)
!_PyArg_NoKeywords("teedataobject", kwargs)) { !_PyArg_NoKeywords("teedataobject", kwargs)) {
goto exit; goto exit;
} }
if (!PyArg_ParseTuple(args, "OO!O:teedataobject", if (!_PyArg_CheckPositional("teedataobject", PyTuple_GET_SIZE(args), 3, 3)) {
&it, &PyList_Type, &values, &next)) {
goto exit; 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); return_value = itertools_teedataobject_impl(type, it, values, next);
exit: exit:
@ -143,10 +154,31 @@ itertools_tee(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *iterable; PyObject *iterable;
Py_ssize_t n = 2; Py_ssize_t n = 2;
if (!_PyArg_ParseStack(args, nargs, "O|n:tee", if (!_PyArg_CheckPositional("tee", nargs, 1, 2)) {
&iterable, &n)) {
goto exit; 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); return_value = itertools_tee_impl(module, iterable, n);
exit: exit:
@ -510,4 +542,4 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs)
exit: exit:
return return_value; 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; double x;
PyObject *i; PyObject *i;
if (!_PyArg_ParseStack(args, nargs, "dO:ldexp", if (!_PyArg_CheckPositional("ldexp", nargs, 2, 2)) {
&x, &i)) {
goto exit; goto exit;
} }
x = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
i = args[1];
return_value = math_ldexp_impl(module, x, i); return_value = math_ldexp_impl(module, x, i);
exit: exit:
@ -261,8 +265,15 @@ math_fmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
double x; double x;
double y; double y;
if (!_PyArg_ParseStack(args, nargs, "dd:fmod", if (!_PyArg_CheckPositional("fmod", nargs, 2, 2)) {
&x, &y)) { goto exit;
}
x = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
y = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit; goto exit;
} }
return_value = math_fmod_impl(module, x, y); 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 x;
double y; double y;
if (!_PyArg_ParseStack(args, nargs, "dd:pow", if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) {
&x, &y)) { goto exit;
}
x = PyFloat_AsDouble(args[0]);
if (PyErr_Occurred()) {
goto exit;
}
y = PyFloat_AsDouble(args[1]);
if (PyErr_Occurred()) {
goto exit; goto exit;
} }
return_value = math_pow_impl(module, x, y); 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: exit:
return return_value; 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); path_t path = PATH_T_INITIALIZE("execv", "path", 0, 0);
PyObject *argv; PyObject *argv;
if (!_PyArg_ParseStack(args, nargs, "O&O:execv", if (!_PyArg_CheckPositional("execv", nargs, 2, 2)) {
path_converter, &path, &argv)) {
goto exit; goto exit;
} }
if (!path_converter(args[0], &path)) {
goto exit;
}
argv = args[1];
return_value = os_execv_impl(module, &path, argv); return_value = os_execv_impl(module, &path, argv);
exit: 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); path_t path = PATH_T_INITIALIZE("spawnv", "path", 0, 0);
PyObject *argv; PyObject *argv;
if (!_PyArg_ParseStack(args, nargs, "iO&O:spawnv", if (!_PyArg_CheckPositional("spawnv", nargs, 3, 3)) {
&mode, path_converter, &path, &argv)) {
goto exit; 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); return_value = os_spawnv_impl(module, mode, &path, argv);
exit: exit:
@ -1865,10 +1880,23 @@ os_spawnve(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *argv; PyObject *argv;
PyObject *env; PyObject *env;
if (!_PyArg_ParseStack(args, nargs, "iO&OO:spawnve", if (!_PyArg_CheckPositional("spawnve", nargs, 4, 4)) {
&mode, path_converter, &path, &argv, &env)) {
goto exit; 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); return_value = os_spawnve_impl(module, mode, &path, argv, env);
exit: exit:
@ -2874,8 +2902,13 @@ os_setreuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
uid_t ruid; uid_t ruid;
uid_t euid; uid_t euid;
if (!_PyArg_ParseStack(args, nargs, "O&O&:setreuid", if (!_PyArg_CheckPositional("setreuid", nargs, 2, 2)) {
_Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) { goto exit;
}
if (!_Py_Uid_Converter(args[0], &ruid)) {
goto exit;
}
if (!_Py_Uid_Converter(args[1], &euid)) {
goto exit; goto exit;
} }
return_value = os_setreuid_impl(module, ruid, euid); 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 rgid;
gid_t egid; gid_t egid;
if (!_PyArg_ParseStack(args, nargs, "O&O&:setregid", if (!_PyArg_CheckPositional("setregid", nargs, 2, 2)) {
_Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) { goto exit;
}
if (!_Py_Gid_Converter(args[0], &rgid)) {
goto exit;
}
if (!_Py_Gid_Converter(args[1], &egid)) {
goto exit; goto exit;
} }
return_value = os_setregid_impl(module, rgid, egid); 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_low;
int fd_high; int fd_high;
if (!_PyArg_ParseStack(args, nargs, "ii:closerange", if (!_PyArg_CheckPositional("closerange", nargs, 2, 2)) {
&fd_low, &fd_high)) { 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; goto exit;
} }
return_value = os_closerange_impl(module, fd_low, fd_high); 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; int command;
Py_off_t length; Py_off_t length;
if (!_PyArg_ParseStack(args, nargs, "iiO&:lockf", if (!_PyArg_CheckPositional("lockf", nargs, 3, 3)) {
&fd, &command, Py_off_t_converter, &length)) { 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; goto exit;
} }
return_value = os_lockf_impl(module, fd, command, length); 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; int how;
Py_off_t _return_value; Py_off_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO&i:lseek", if (!_PyArg_CheckPositional("lseek", nargs, 3, 3)) {
&fd, Py_off_t_converter, &position, &how)) { 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; goto exit;
} }
_return_value = os_lseek_impl(module, fd, position, how); _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; int fd;
Py_ssize_t length; Py_ssize_t length;
if (!_PyArg_ParseStack(args, nargs, "in:read", if (!_PyArg_CheckPositional("read", nargs, 2, 2)) {
&fd, &length)) {
goto exit; 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); return_value = os_read_impl(module, fd, length);
exit: exit:
@ -3781,10 +3901,19 @@ os_readv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *buffers; PyObject *buffers;
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO:readv", if (!_PyArg_CheckPositional("readv", nargs, 2, 2)) {
&fd, &buffers)) {
goto exit; 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); _return_value = os_readv_impl(module, fd, buffers);
if ((_return_value == -1) && PyErr_Occurred()) { if ((_return_value == -1) && PyErr_Occurred()) {
goto exit; goto exit;
@ -3822,8 +3951,28 @@ os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int length; int length;
Py_off_t offset; Py_off_t offset;
if (!_PyArg_ParseStack(args, nargs, "iiO&:pread", if (!_PyArg_CheckPositional("pread", nargs, 3, 3)) {
&fd, &length, Py_off_t_converter, &offset)) { 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; goto exit;
} }
return_value = os_pread_impl(module, fd, length, offset); 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; int flags = 0;
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iOO&|i:preadv", if (!_PyArg_CheckPositional("preadv", nargs, 3, 4)) {
&fd, &buffers, Py_off_t_converter, &offset, &flags)) {
goto exit; 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); _return_value = os_preadv_impl(module, fd, buffers, offset, flags);
if ((_return_value == -1) && PyErr_Occurred()) { if ((_return_value == -1) && PyErr_Occurred()) {
goto exit; goto exit;
@ -3909,8 +4083,23 @@ os_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL}; Py_buffer data = {NULL, NULL};
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iy*:write", if (!_PyArg_CheckPositional("write", nargs, 2, 2)) {
&fd, &data)) { 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; goto exit;
} }
_return_value = os_write_impl(module, fd, &data); _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 outfd;
int flags; int flags;
if (!_PyArg_ParseStack(args, nargs, "iii:_fcopyfile", if (!_PyArg_CheckPositional("_fcopyfile", nargs, 3, 3)) {
&infd, &outfd, &flags)) { 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; goto exit;
} }
return_value = os__fcopyfile_impl(module, infd, outfd, flags); 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; PyObject *buffers;
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO:writev", if (!_PyArg_CheckPositional("writev", nargs, 2, 2)) {
&fd, &buffers)) {
goto exit; 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); _return_value = os_writev_impl(module, fd, buffers);
if ((_return_value == -1) && PyErr_Occurred()) { if ((_return_value == -1) && PyErr_Occurred()) {
goto exit; goto exit;
@ -4172,8 +4396,26 @@ os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_off_t offset; Py_off_t offset;
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iy*O&:pwrite", if (!_PyArg_CheckPositional("pwrite", nargs, 3, 3)) {
&fd, &buffer, Py_off_t_converter, &offset)) { 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; goto exit;
} }
_return_value = os_pwrite_impl(module, fd, &buffer, offset); _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; int flags = 0;
Py_ssize_t _return_value; Py_ssize_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "iOO&|i:pwritev", if (!_PyArg_CheckPositional("pwritev", nargs, 3, 4)) {
&fd, &buffers, Py_off_t_converter, &offset, &flags)) {
goto exit; 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); _return_value = os_pwritev_impl(module, fd, buffers, offset, flags);
if ((_return_value == -1) && PyErr_Occurred()) { if ((_return_value == -1) && PyErr_Occurred()) {
goto exit; goto exit;
@ -4439,8 +4706,25 @@ os_makedev(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int minor; int minor;
dev_t _return_value; dev_t _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:makedev", if (!_PyArg_CheckPositional("makedev", nargs, 2, 2)) {
&major, &minor)) { 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; goto exit;
} }
_return_value = os_makedev_impl(module, major, minor); _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; int fd;
Py_off_t length; Py_off_t length;
if (!_PyArg_ParseStack(args, nargs, "iO&:ftruncate", if (!_PyArg_CheckPositional("ftruncate", nargs, 2, 2)) {
&fd, Py_off_t_converter, &length)) { 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; goto exit;
} }
return_value = os_ftruncate_impl(module, fd, length); 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 offset;
Py_off_t length; Py_off_t length;
if (!_PyArg_ParseStack(args, nargs, "iO&O&:posix_fallocate", if (!_PyArg_CheckPositional("posix_fallocate", nargs, 3, 3)) {
&fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) { 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; goto exit;
} }
return_value = os_posix_fallocate_impl(module, fd, offset, length); 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; Py_off_t length;
int advice; int advice;
if (!_PyArg_ParseStack(args, nargs, "iO&O&i:posix_fadvise", if (!_PyArg_CheckPositional("posix_fadvise", nargs, 4, 4)) {
&fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) { 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; goto exit;
} }
return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); 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 *name;
PyObject *value; PyObject *value;
if (!_PyArg_ParseStack(args, nargs, "UU:putenv", if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) {
&name, &value)) {
goto exit; 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); return_value = os_putenv_impl(module, name, value);
exit: exit:
@ -4665,8 +5012,13 @@ os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *name = NULL; PyObject *name = NULL;
PyObject *value = NULL; PyObject *value = NULL;
if (!_PyArg_ParseStack(args, nargs, "O&O&:putenv", if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) {
PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) { goto exit;
}
if (!PyUnicode_FSConverter(args[0], &name)) {
goto exit;
}
if (!PyUnicode_FSConverter(args[1], &value)) {
goto exit; goto exit;
} }
return_value = os_putenv_impl(module, name, value); 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; int name;
long _return_value; long _return_value;
if (!_PyArg_ParseStack(args, nargs, "iO&:fpathconf", if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) {
&fd, conv_path_confname, &name)) { 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; goto exit;
} }
_return_value = os_fpathconf_impl(module, fd, name); _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 euid;
uid_t suid; uid_t suid;
if (!_PyArg_ParseStack(args, nargs, "O&O&O&:setresuid", if (!_PyArg_CheckPositional("setresuid", nargs, 3, 3)) {
_Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) { 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; goto exit;
} }
return_value = os_setresuid_impl(module, ruid, euid, suid); 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 egid;
gid_t sgid; gid_t sgid;
if (!_PyArg_ParseStack(args, nargs, "O&O&O&:setresgid", if (!_PyArg_CheckPositional("setresgid", nargs, 3, 3)) {
_Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) { 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; goto exit;
} }
return_value = os_setresgid_impl(module, rgid, egid, sgid); 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 fd;
int inheritable; int inheritable;
if (!_PyArg_ParseStack(args, nargs, "ii:set_inheritable", if (!_PyArg_CheckPositional("set_inheritable", nargs, 2, 2)) {
&fd, &inheritable)) { 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; goto exit;
} }
return_value = os_set_inheritable_impl(module, fd, inheritable); 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 fd;
int blocking; int blocking;
if (!_PyArg_ParseStack(args, nargs, "ii:set_blocking", if (!_PyArg_CheckPositional("set_blocking", nargs, 2, 2)) {
&fd, &blocking)) { 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; goto exit;
} }
return_value = os_set_blocking_impl(module, fd, blocking); return_value = os_set_blocking_impl(module, fd, blocking);
@ -6845,4 +7258,4 @@ exit:
#ifndef OS_GETRANDOM_METHODDEF #ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF #define OS_GETRANDOM_METHODDEF
#endif /* !defined(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; PyObject *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("getpwnam", "str", arg); _PyArg_BadArgument("getpwnam", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -74,4 +74,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef PWD_GETPWALL_METHODDEF #ifndef PWD_GETPWALL_METHODDEF
#define PWD_GETPWALL_METHODDEF #define PWD_GETPWALL_METHODDEF
#endif /* !defined(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; PyObject *data;
int isfinal = 0; int isfinal = 0;
if (!_PyArg_ParseStack(args, nargs, "O|i:Parse", if (!_PyArg_CheckPositional("Parse", nargs, 1, 2)) {
&data, &isfinal)) {
goto exit; 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); return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal);
exit: exit:
@ -62,7 +75,7 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
const char *base; const char *base;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("SetBase", "str", arg); _PyArg_BadArgument("SetBase", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t base_length; Py_ssize_t base_length;
@ -140,10 +153,44 @@ pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *con
const char *context; const char *context;
const char *encoding = NULL; const char *encoding = NULL;
if (!_PyArg_ParseStack(args, nargs, "z|s:ExternalEntityParserCreate", if (!_PyArg_CheckPositional("ExternalEntityParserCreate", nargs, 1, 2)) {
&context, &encoding)) {
goto exit; 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); return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding);
exit: exit:
@ -212,10 +259,17 @@ pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *const *args, Py_
PyObject *return_value = NULL; PyObject *return_value = NULL;
int flag = 1; int flag = 1;
if (!_PyArg_ParseStack(args, nargs, "|p:UseForeignDTD", if (!_PyArg_CheckPositional("UseForeignDTD", nargs, 0, 1)) {
&flag)) {
goto exit; 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); return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag);
exit: exit:
@ -294,4 +348,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(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; int resource;
PyObject *limits; PyObject *limits;
if (!_PyArg_ParseStack(args, nargs, "iO:setrlimit", if (!_PyArg_CheckPositional("setrlimit", nargs, 2, 2)) {
&resource, &limits)) {
goto exit; 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); return_value = resource_setrlimit_impl(module, resource, limits);
exit: exit:
@ -169,4 +178,4 @@ exit:
#ifndef RESOURCE_PRLIMIT_METHODDEF #ifndef RESOURCE_PRLIMIT_METHODDEF
#define RESOURCE_PRLIMIT_METHODDEF #define RESOURCE_PRLIMIT_METHODDEF
#endif /* !defined(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; int fd;
unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;
if (!_PyArg_ParseStack(args, nargs, "O&|O&:register", if (!_PyArg_CheckPositional("register", nargs, 1, 2)) {
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
goto exit; 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); return_value = select_poll_register_impl(self, fd, eventmask);
exit: exit:
@ -121,8 +130,13 @@ select_poll_modify(pollObject *self, PyObject *const *args, Py_ssize_t nargs)
int fd; int fd;
unsigned short eventmask; unsigned short eventmask;
if (!_PyArg_ParseStack(args, nargs, "O&O&:modify", if (!_PyArg_CheckPositional("modify", nargs, 2, 2)) {
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) { goto exit;
}
if (!fildes_converter(args[0], &fd)) {
goto exit;
}
if (!_PyLong_UnsignedShort_Converter(args[1], &eventmask)) {
goto exit; goto exit;
} }
return_value = select_poll_modify_impl(self, fd, eventmask); 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; int fd;
unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;
if (!_PyArg_ParseStack(args, nargs, "O&|O&:register", if (!_PyArg_CheckPositional("register", nargs, 1, 2)) {
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
goto exit; 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); return_value = select_devpoll_register_impl(self, fd, eventmask);
exit: exit:
@ -268,10 +291,19 @@ select_devpoll_modify(devpollObject *self, PyObject *const *args, Py_ssize_t nar
int fd; int fd;
unsigned short eventmask = POLLIN | POLLPRI | POLLOUT; unsigned short eventmask = POLLIN | POLLPRI | POLLOUT;
if (!_PyArg_ParseStack(args, nargs, "O&|O&:modify", if (!_PyArg_CheckPositional("modify", nargs, 1, 2)) {
fildes_converter, &fd, _PyLong_UnsignedShort_Converter, &eventmask)) {
goto exit; 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); return_value = select_devpoll_modify_impl(self, fd, eventmask);
exit: exit:
@ -948,10 +980,24 @@ select_kqueue_control(kqueue_queue_Object *self, PyObject *const *args, Py_ssize
int maxevents; int maxevents;
PyObject *otimeout = Py_None; PyObject *otimeout = Py_None;
if (!_PyArg_ParseStack(args, nargs, "Oi|O:control", if (!_PyArg_CheckPositional("control", nargs, 2, 3)) {
&changelist, &maxevents, &otimeout)) {
goto exit; 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); return_value = select_kqueue_control_impl(self, changelist, maxevents, otimeout);
exit: exit:
@ -1059,4 +1105,4 @@ exit:
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF #ifndef SELECT_KQUEUE_CONTROL_METHODDEF
#define SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF
#endif /* !defined(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; int signalnum;
PyObject *handler; PyObject *handler;
if (!_PyArg_ParseStack(args, nargs, "iO:signal", if (!_PyArg_CheckPositional("signal", nargs, 2, 2)) {
&signalnum, &handler)) {
goto exit; 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); return_value = signal_signal_impl(module, signalnum, handler);
exit: exit:
@ -234,8 +243,25 @@ signal_siginterrupt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
int signalnum; int signalnum;
int flag; int flag;
if (!_PyArg_ParseStack(args, nargs, "ii:siginterrupt", if (!_PyArg_CheckPositional("siginterrupt", nargs, 2, 2)) {
&signalnum, &flag)) { 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; goto exit;
} }
return_value = signal_siginterrupt_impl(module, signalnum, flag); 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 *seconds;
PyObject *interval = NULL; PyObject *interval = NULL;
if (!_PyArg_ParseStack(args, nargs, "iO|O:setitimer", if (!_PyArg_CheckPositional("setitimer", nargs, 2, 3)) {
&which, &seconds, &interval)) {
goto exit; 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); return_value = signal_setitimer_impl(module, which, seconds, interval);
exit: exit:
@ -344,8 +384,19 @@ signal_pthread_sigmask(PyObject *module, PyObject *const *args, Py_ssize_t nargs
int how; int how;
sigset_t mask; sigset_t mask;
if (!_PyArg_ParseStack(args, nargs, "iO&:pthread_sigmask", if (!_PyArg_CheckPositional("pthread_sigmask", nargs, 2, 2)) {
&how, _Py_Sigset_Converter, &mask)) { 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; goto exit;
} }
return_value = signal_pthread_sigmask_impl(module, how, mask); 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; sigset_t sigset;
PyObject *timeout_obj; PyObject *timeout_obj;
if (!_PyArg_ParseStack(args, nargs, "O&O:sigtimedwait", if (!_PyArg_CheckPositional("sigtimedwait", nargs, 2, 2)) {
_Py_Sigset_Converter, &sigset, &timeout_obj)) {
goto exit; goto exit;
} }
if (!_Py_Sigset_Converter(args[0], &sigset)) {
goto exit;
}
timeout_obj = args[1];
return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj); return_value = signal_sigtimedwait_impl(module, sigset, timeout_obj);
exit: exit:
@ -532,8 +586,21 @@ signal_pthread_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
unsigned long thread_id; unsigned long thread_id;
int signalnum; int signalnum;
if (!_PyArg_ParseStack(args, nargs, "ki:pthread_kill", if (!_PyArg_CheckPositional("pthread_kill", nargs, 2, 2)) {
&thread_id, &signalnum)) { 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; goto exit;
} }
return_value = signal_pthread_kill_impl(module, thread_id, signalnum); return_value = signal_pthread_kill_impl(module, thread_id, signalnum);
@ -591,4 +658,4 @@ exit:
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF #ifndef SIGNAL_PTHREAD_KILL_METHODDEF
#define SIGNAL_PTHREAD_KILL_METHODDEF #define SIGNAL_PTHREAD_KILL_METHODDEF
#endif /* !defined(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; PyObject *arg;
if (!PyUnicode_Check(arg_)) { if (!PyUnicode_Check(arg_)) {
_PyArg_BadArgument("getspnam", "str", arg_); _PyArg_BadArgument("getspnam", 0, "str", arg_);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg_) == -1) { if (PyUnicode_READY(arg_) == -1) {
@ -71,4 +71,4 @@ spwd_getspall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef SPWD_GETSPALL_METHODDEF #ifndef SPWD_GETSPALL_METHODDEF
#define SPWD_GETSPALL_METHODDEF #define SPWD_GETSPALL_METHODDEF
#endif /* !defined(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; PyObject *filename;
const char *startstr; const char *startstr;
if (!_PyArg_ParseStack(args, nargs, "sO&s:symtable", if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) {
&str, PyUnicode_FSDecoder, &filename, &startstr)) { 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; goto exit;
} }
return_value = _symtable_symtable_impl(module, str, filename, startstr); 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: exit:
return return_value; 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; int chr;
PyObject *default_value = NULL; PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:decimal", if (!_PyArg_CheckPositional("decimal", nargs, 1, 2)) {
&chr, &default_value)) {
goto exit; 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); return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
exit: exit:
@ -59,10 +75,26 @@ unicodedata_UCD_digit(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr; int chr;
PyObject *default_value = NULL; PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:digit", if (!_PyArg_CheckPositional("digit", nargs, 1, 2)) {
&chr, &default_value)) {
goto exit; 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); return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
exit: exit:
@ -93,10 +125,26 @@ unicodedata_UCD_numeric(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr; int chr;
PyObject *default_value = NULL; PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:numeric", if (!_PyArg_CheckPositional("numeric", nargs, 1, 2)) {
&chr, &default_value)) {
goto exit; 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); return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
exit: exit:
@ -122,14 +170,14 @@ unicodedata_UCD_category(PyObject *self, PyObject *arg)
int chr; int chr;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("category", "a unicode character", arg); _PyArg_BadArgument("category", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("category", "a unicode character", arg); _PyArg_BadArgument("category", 0, "a unicode character", arg);
goto exit; goto exit;
} }
chr = PyUnicode_READ_CHAR(arg, 0); chr = PyUnicode_READ_CHAR(arg, 0);
@ -160,14 +208,14 @@ unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
int chr; int chr;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("bidirectional", "a unicode character", arg); _PyArg_BadArgument("bidirectional", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("bidirectional", "a unicode character", arg); _PyArg_BadArgument("bidirectional", 0, "a unicode character", arg);
goto exit; goto exit;
} }
chr = PyUnicode_READ_CHAR(arg, 0); chr = PyUnicode_READ_CHAR(arg, 0);
@ -199,14 +247,14 @@ unicodedata_UCD_combining(PyObject *self, PyObject *arg)
int _return_value; int _return_value;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("combining", "a unicode character", arg); _PyArg_BadArgument("combining", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("combining", "a unicode character", arg); _PyArg_BadArgument("combining", 0, "a unicode character", arg);
goto exit; goto exit;
} }
chr = PyUnicode_READ_CHAR(arg, 0); chr = PyUnicode_READ_CHAR(arg, 0);
@ -243,14 +291,14 @@ unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
int _return_value; int _return_value;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("mirrored", "a unicode character", arg); _PyArg_BadArgument("mirrored", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("mirrored", "a unicode character", arg); _PyArg_BadArgument("mirrored", 0, "a unicode character", arg);
goto exit; goto exit;
} }
chr = PyUnicode_READ_CHAR(arg, 0); chr = PyUnicode_READ_CHAR(arg, 0);
@ -283,14 +331,14 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
int chr; int chr;
if (!PyUnicode_Check(arg)) { 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; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { 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; goto exit;
} }
chr = PyUnicode_READ_CHAR(arg, 0); chr = PyUnicode_READ_CHAR(arg, 0);
@ -321,14 +369,14 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
int chr; int chr;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("decomposition", "a unicode character", arg); _PyArg_BadArgument("decomposition", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("decomposition", "a unicode character", arg); _PyArg_BadArgument("decomposition", 0, "a unicode character", arg);
goto exit; goto exit;
} }
chr = PyUnicode_READ_CHAR(arg, 0); 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 *form;
PyObject *input; PyObject *input;
if (!_PyArg_ParseStack(args, nargs, "UU:is_normalized", if (!_PyArg_CheckPositional("is_normalized", nargs, 2, 2)) {
&form, &input)) {
goto exit; 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); return_value = unicodedata_UCD_is_normalized_impl(self, form, input);
exit: exit:
@ -392,10 +455,25 @@ unicodedata_UCD_normalize(PyObject *self, PyObject *const *args, Py_ssize_t narg
PyObject *form; PyObject *form;
PyObject *input; PyObject *input;
if (!_PyArg_ParseStack(args, nargs, "UU:normalize", if (!_PyArg_CheckPositional("normalize", nargs, 2, 2)) {
&form, &input)) {
goto exit; 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); return_value = unicodedata_UCD_normalize_impl(self, form, input);
exit: exit:
@ -424,10 +502,26 @@ unicodedata_UCD_name(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
int chr; int chr;
PyObject *default_value = NULL; PyObject *default_value = NULL;
if (!_PyArg_ParseStack(args, nargs, "C|O:name", if (!_PyArg_CheckPositional("name", nargs, 1, 2)) {
&chr, &default_value)) {
goto exit; 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); return_value = unicodedata_UCD_name_impl(self, chr, default_value);
exit: exit:
@ -465,4 +559,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
exit: exit:
return return_value; 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; goto exit;
} }
if (!PyBuffer_IsContiguous(&data, 'C')) { if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg); _PyArg_BadArgument("compress", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = zlib_Compress_compress_impl(self, &data); 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; PyObject *return_value = NULL;
int mode = Z_FINISH; int mode = Z_FINISH;
if (!_PyArg_ParseStack(args, nargs, "|i:flush", if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) {
&mode)) {
goto exit; 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); return_value = zlib_Compress_flush_impl(self, mode);
exit: exit:
@ -446,10 +458,16 @@ zlib_Decompress_flush(compobject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t length = DEF_BUF_SIZE; Py_ssize_t length = DEF_BUF_SIZE;
if (!_PyArg_ParseStack(args, nargs, "|O&:flush", if (!_PyArg_CheckPositional("flush", nargs, 0, 1)) {
ssize_t_converter, &length)) {
goto exit; 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); return_value = zlib_Decompress_flush_impl(self, length);
exit: exit:
@ -480,10 +498,29 @@ zlib_adler32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL}; Py_buffer data = {NULL, NULL};
unsigned int value = 1; unsigned int value = 1;
if (!_PyArg_ParseStack(args, nargs, "y*|I:adler32", if (!_PyArg_CheckPositional("adler32", nargs, 1, 2)) {
&data, &value)) {
goto exit; 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); return_value = zlib_adler32_impl(module, &data, value);
exit: exit:
@ -519,10 +556,29 @@ zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_buffer data = {NULL, NULL}; Py_buffer data = {NULL, NULL};
unsigned int value = 0; unsigned int value = 0;
if (!_PyArg_ParseStack(args, nargs, "y*|I:crc32", if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) {
&data, &value)) {
goto exit; 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); return_value = zlib_crc32_impl(module, &data, value);
exit: exit:
@ -557,4 +613,4 @@ exit:
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#endif /* !defined(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 frm = {NULL, NULL};
Py_buffer to = {NULL, NULL}; Py_buffer to = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) {
&frm, &to)) { 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; goto exit;
} }
return_value = bytearray_maketrans_impl(&frm, &to); 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_buffer new = {NULL, NULL};
Py_ssize_t count = -1; Py_ssize_t count = -1;
if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
&old, &new, &count)) {
goto exit; 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); return_value = bytearray_replace_impl(self, &old, &new, count);
exit: exit:
@ -323,8 +370,27 @@ bytearray_insert(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg
Py_ssize_t index; Py_ssize_t index;
int item; int item;
if (!_PyArg_ParseStack(args, nargs, "nO&:insert", if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
&index, _getbytevalue, &item)) { 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; goto exit;
} }
return_value = bytearray_insert_impl(self, index, item); 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; PyObject *return_value = NULL;
Py_ssize_t index = -1; Py_ssize_t index = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:pop", if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
&index)) {
goto exit; 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); return_value = bytearray_pop_impl(self, index);
exit: exit:
@ -641,7 +727,7 @@ bytearray_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *string; PyObject *string;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", "str", arg); _PyArg_BadArgument("fromhex", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { 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; PyObject *return_value = NULL;
int proto = 0; int proto = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:__reduce_ex__", if (!_PyArg_CheckPositional("__reduce_ex__", nargs, 0, 1)) {
&proto)) {
goto exit; 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); return_value = bytearray_reduce_ex_impl(self, proto);
exit: exit:
@ -717,4 +815,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{ {
return bytearray_sizeof_impl(self); 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; goto exit;
} }
if (!PyBuffer_IsContiguous(&sep, 'C')) { if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("partition", "contiguous buffer", arg); _PyArg_BadArgument("partition", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = bytes_partition_impl(self, &sep); return_value = bytes_partition_impl(self, &sep);
@ -113,7 +113,7 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&sep, 'C')) { if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("rpartition", "contiguous buffer", arg); _PyArg_BadArgument("rpartition", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = bytes_rpartition_impl(self, &sep); 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 frm = {NULL, NULL};
Py_buffer to = {NULL, NULL}; Py_buffer to = {NULL, NULL};
if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", if (!_PyArg_CheckPositional("maketrans", nargs, 2, 2)) {
&frm, &to)) { 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; goto exit;
} }
return_value = bytes_maketrans_impl(&frm, &to); 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_buffer new = {NULL, NULL};
Py_ssize_t count = -1; Py_ssize_t count = -1;
if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
&old, &new, &count)) {
goto exit; 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); return_value = bytes_replace_impl(self, &old, &new, count);
exit: exit:
@ -500,7 +547,7 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *string; PyObject *string;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", "str", arg); _PyArg_BadArgument("fromhex", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -512,4 +559,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
exit: exit:
return return_value; 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; const char *typestr;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__getformat__", "str", arg); _PyArg_BadArgument("__getformat__", 0, "str", arg);
goto exit; goto exit;
} }
Py_ssize_t typestr_length; 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 *typestr;
const char *fmt; const char *fmt;
if (!_PyArg_ParseStack(args, nargs, "ss:__set_format__", if (!_PyArg_CheckPositional("__set_format__", nargs, 2, 2)) {
&typestr, &fmt)) { 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; goto exit;
} }
return_value = float___set_format___impl(type, typestr, fmt); return_value = float___set_format___impl(type, typestr, fmt);
@ -308,7 +333,7 @@ float___format__(PyObject *self, PyObject *arg)
PyObject *format_spec; PyObject *format_spec;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg); _PyArg_BadArgument("__format__", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -320,4 +345,4 @@ float___format__(PyObject *self, PyObject *arg)
exit: exit:
return return_value; 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; Py_ssize_t index;
PyObject *object; PyObject *object;
if (!_PyArg_ParseStack(args, nargs, "nO:insert", if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
&index, &object)) {
goto exit; 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); return_value = list_insert_impl(self, index, object);
exit: exit:
@ -105,10 +122,30 @@ list_pop(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
Py_ssize_t index = -1; Py_ssize_t index = -1;
if (!_PyArg_ParseStack(args, nargs, "|n:pop", if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
&index)) {
goto exit; 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); return_value = list_pop_impl(self, index);
exit: exit:
@ -187,10 +224,23 @@ list_index(PyListObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t start = 0; Py_ssize_t start = 0;
Py_ssize_t stop = PY_SSIZE_T_MAX; Py_ssize_t stop = PY_SSIZE_T_MAX;
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index", if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
&value, _PyEval_SliceIndexNotNone, &start, _PyEval_SliceIndexNotNone, &stop)) {
goto exit; 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); return_value = list_index_impl(self, value, start, stop);
exit: exit:
@ -285,4 +335,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
{ {
return list___reversed___impl(self); 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; PyObject *format_spec;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg); _PyArg_BadArgument("__format__", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -244,4 +244,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb
exit: exit:
return return_value; 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 start = 0;
Py_ssize_t stop = PY_SSIZE_T_MAX; Py_ssize_t stop = PY_SSIZE_T_MAX;
if (!_PyArg_ParseStack(args, nargs, "O|O&O&:index", if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
&value, _PyEval_SliceIndexNotNone, &start, _PyEval_SliceIndexNotNone, &stop)) {
goto exit; 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); return_value = tuple_index_impl(self, value, start, stop);
exit: exit:
@ -95,4 +108,4 @@ tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored))
{ {
return tuple___getnewargs___impl(self); 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; PyObject *format_spec;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg); _PyArg_BadArgument("__format__", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -248,4 +248,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
{ {
return object___dir___impl(self); 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_ssize_t width;
Py_UCS4 fillchar = ' '; Py_UCS4 fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|O&:center", if (!_PyArg_CheckPositional("center", nargs, 1, 2)) {
&width, convert_uc, &fillchar)) {
goto exit; 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); return_value = unicode_center_impl(self, width, fillchar);
exit: exit:
@ -452,10 +475,33 @@ unicode_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width; Py_ssize_t width;
Py_UCS4 fillchar = ' '; Py_UCS4 fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|O&:ljust", if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) {
&width, convert_uc, &fillchar)) {
goto exit; 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); return_value = unicode_ljust_impl(self, width, fillchar);
exit: exit:
@ -601,10 +647,46 @@ unicode_replace(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *new; PyObject *new;
Py_ssize_t count = -1; Py_ssize_t count = -1;
if (!_PyArg_ParseStack(args, nargs, "UU|n:replace", if (!_PyArg_CheckPositional("replace", nargs, 2, 3)) {
&old, &new, &count)) {
goto exit; 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); return_value = unicode_replace_impl(self, old, new, count);
exit: exit:
@ -632,10 +714,33 @@ unicode_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width; Py_ssize_t width;
Py_UCS4 fillchar = ' '; Py_UCS4 fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|O&:rjust", if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) {
&width, convert_uc, &fillchar)) {
goto exit; 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); return_value = unicode_rjust_impl(self, width, fillchar);
exit: exit:
@ -833,10 +938,33 @@ unicode_maketrans(void *null, PyObject *const *args, Py_ssize_t nargs)
PyObject *y = NULL; PyObject *y = NULL;
PyObject *z = NULL; PyObject *z = NULL;
if (!_PyArg_ParseStack(args, nargs, "O|UU:maketrans", if (!_PyArg_CheckPositional("maketrans", nargs, 1, 3)) {
&x, &y, &z)) {
goto exit; 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); return_value = unicode_maketrans_impl(x, y, z);
exit: exit:
@ -940,7 +1068,7 @@ unicode___format__(PyObject *self, PyObject *arg)
PyObject *format_spec; PyObject *format_spec;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg); _PyArg_BadArgument("__format__", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -970,4 +1098,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
{ {
return unicode_sizeof_impl(self); 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; Py_ssize_t width;
char fillchar = ' '; char fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|c:ljust", if (!_PyArg_CheckPositional("ljust", nargs, 1, 2)) {
&width, &fillchar)) {
goto exit; 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); return_value = stringlib_ljust_impl(self, width, fillchar);
exit: exit:
@ -86,10 +116,40 @@ stringlib_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width; Py_ssize_t width;
char fillchar = ' '; char fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|c:rjust", if (!_PyArg_CheckPositional("rjust", nargs, 1, 2)) {
&width, &fillchar)) {
goto exit; 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); return_value = stringlib_rjust_impl(self, width, fillchar);
exit: exit:
@ -117,10 +177,40 @@ stringlib_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
Py_ssize_t width; Py_ssize_t width;
char fillchar = ' '; char fillchar = ' ';
if (!_PyArg_ParseStack(args, nargs, "n|c:center", if (!_PyArg_CheckPositional("center", nargs, 1, 2)) {
&width, &fillchar)) {
goto exit; 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); return_value = stringlib_center_impl(self, width, fillchar);
exit: exit:
@ -169,4 +259,4 @@ stringlib_zfill(PyObject *self, PyObject *arg)
exit: exit:
return return_value; 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; int mode;
long nbytes; long nbytes;
if (!_PyArg_ParseStack(args, nargs, "iil:locking", if (!_PyArg_CheckPositional("locking", nargs, 3, 3)) {
&fd, &mode, &nbytes)) { 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; goto exit;
} }
return_value = msvcrt_locking_impl(module, fd, mode, nbytes); 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; int flags;
long _return_value; long _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:setmode", if (!_PyArg_CheckPositional("setmode", nargs, 2, 2)) {
&fd, &flags)) { 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; goto exit;
} }
_return_value = msvcrt_setmode_impl(module, fd, flags); _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]; char_value = PyByteArray_AS_STRING(arg)[0];
} }
else { else {
_PyArg_BadArgument("putch", "a byte string of length 1", arg); _PyArg_BadArgument("putch", 0, "a byte string of length 1", arg);
goto exit; goto exit;
} }
return_value = msvcrt_putch_impl(module, char_value); return_value = msvcrt_putch_impl(module, char_value);
@ -360,14 +403,14 @@ msvcrt_putwch(PyObject *module, PyObject *arg)
int unicode_char; int unicode_char;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("putwch", "a unicode character", arg); _PyArg_BadArgument("putwch", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("putwch", "a unicode character", arg); _PyArg_BadArgument("putwch", 0, "a unicode character", arg);
goto exit; goto exit;
} }
unicode_char = PyUnicode_READ_CHAR(arg, 0); unicode_char = PyUnicode_READ_CHAR(arg, 0);
@ -406,7 +449,7 @@ msvcrt_ungetch(PyObject *module, PyObject *arg)
char_value = PyByteArray_AS_STRING(arg)[0]; char_value = PyByteArray_AS_STRING(arg)[0];
} }
else { else {
_PyArg_BadArgument("ungetch", "a byte string of length 1", arg); _PyArg_BadArgument("ungetch", 0, "a byte string of length 1", arg);
goto exit; goto exit;
} }
return_value = msvcrt_ungetch_impl(module, char_value); return_value = msvcrt_ungetch_impl(module, char_value);
@ -434,14 +477,14 @@ msvcrt_ungetwch(PyObject *module, PyObject *arg)
int unicode_char; int unicode_char;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("ungetwch", "a unicode character", arg); _PyArg_BadArgument("ungetwch", 0, "a unicode character", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg)) { if (PyUnicode_READY(arg)) {
goto exit; goto exit;
} }
if (PyUnicode_GET_LENGTH(arg) != 1) { if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("ungetwch", "a unicode character", arg); _PyArg_BadArgument("ungetwch", 0, "a unicode character", arg);
goto exit; goto exit;
} }
unicode_char = PyUnicode_READ_CHAR(arg, 0); unicode_char = PyUnicode_READ_CHAR(arg, 0);
@ -515,8 +558,25 @@ msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t narg
int mode; int mode;
long _return_value; long _return_value;
if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportMode", if (!_PyArg_CheckPositional("CrtSetReportMode", nargs, 2, 2)) {
&type, &mode)) { 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; goto exit;
} }
_return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
@ -619,4 +679,4 @@ exit:
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
#define MSVCRT_SET_ERROR_MODE_METHODDEF #define MSVCRT_SET_ERROR_MODE_METHODDEF
#endif /* !defined(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; HKEY key;
int index; int index;
if (!_PyArg_ParseStack(args, nargs, "O&i:EnumKey", if (!_PyArg_CheckPositional("EnumKey", nargs, 2, 2)) {
clinic_HKEY_converter, &key, &index)) { 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; goto exit;
} }
return_value = winreg_EnumKey_impl(module, key, index); 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; HKEY key;
int index; int index;
if (!_PyArg_ParseStack(args, nargs, "O&i:EnumValue", if (!_PyArg_CheckPositional("EnumValue", nargs, 2, 2)) {
clinic_HKEY_converter, &key, &index)) { 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; goto exit;
} }
return_value = winreg_EnumValue_impl(module, key, index); return_value = winreg_EnumValue_impl(module, key, index);
@ -1095,4 +1117,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
exit: exit:
return return_value; 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 *value;
PyObject *format_spec = NULL; PyObject *format_spec = NULL;
if (!_PyArg_ParseStack(args, nargs, "O|U:format", if (!_PyArg_CheckPositional("format", nargs, 1, 2)) {
&value, &format_spec)) {
goto exit; 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); return_value = builtin_format_impl(module, value, format_spec);
exit: exit:
@ -717,4 +729,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit: exit:
return return_value; 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; PyCodeObject *code;
PyObject *path; PyObject *path;
if (!_PyArg_ParseStack(args, nargs, "O!U:_fix_co_filename", if (!_PyArg_CheckPositional("_fix_co_filename", nargs, 2, 2)) {
&PyCode_Type, &code, &path)) {
goto exit; 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); return_value = _imp__fix_co_filename_impl(module, code, path);
exit: exit:
@ -144,7 +156,7 @@ _imp_init_frozen(PyObject *module, PyObject *arg)
PyObject *name; PyObject *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("init_frozen", "str", arg); _PyArg_BadArgument("init_frozen", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -176,7 +188,7 @@ _imp_get_frozen_object(PyObject *module, PyObject *arg)
PyObject *name; PyObject *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("get_frozen_object", "str", arg); _PyArg_BadArgument("get_frozen_object", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -208,7 +220,7 @@ _imp_is_frozen_package(PyObject *module, PyObject *arg)
PyObject *name; PyObject *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_frozen_package", "str", arg); _PyArg_BadArgument("is_frozen_package", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -240,7 +252,7 @@ _imp_is_builtin(PyObject *module, PyObject *arg)
PyObject *name; PyObject *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_builtin", "str", arg); _PyArg_BadArgument("is_builtin", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -272,7 +284,7 @@ _imp_is_frozen(PyObject *module, PyObject *arg)
PyObject *name; PyObject *name;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_frozen", "str", arg); _PyArg_BadArgument("is_frozen", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -421,4 +433,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF #ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_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; PyObject *file;
int version = Py_MARSHAL_VERSION; int version = Py_MARSHAL_VERSION;
if (!_PyArg_ParseStack(args, nargs, "OO|i:dump", if (!_PyArg_CheckPositional("dump", nargs, 2, 3)) {
&value, &file, &version)) {
goto exit; 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); return_value = marshal_dump_impl(module, value, file, version);
exit: exit:
@ -90,10 +104,23 @@ marshal_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *value; PyObject *value;
int version = Py_MARSHAL_VERSION; int version = Py_MARSHAL_VERSION;
if (!_PyArg_ParseStack(args, nargs, "O|i:dumps", if (!_PyArg_CheckPositional("dumps", nargs, 1, 2)) {
&value, &version)) {
goto exit; 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); return_value = marshal_dumps_impl(module, value, version);
exit: exit:
@ -125,7 +152,7 @@ marshal_loads(PyObject *module, PyObject *arg)
goto exit; goto exit;
} }
if (!PyBuffer_IsContiguous(&bytes, 'C')) { if (!PyBuffer_IsContiguous(&bytes, 'C')) {
_PyArg_BadArgument("loads", "contiguous buffer", arg); _PyArg_BadArgument("loads", 0, "contiguous buffer", arg);
goto exit; goto exit;
} }
return_value = marshal_loads_impl(module, &bytes); return_value = marshal_loads_impl(module, &bytes);
@ -138,4 +165,4 @@ exit:
return return_value; 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; PyObject *s;
if (!PyUnicode_Check(arg)) { if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("intern", "str", arg); _PyArg_BadArgument("intern", 0, "str", arg);
goto exit; goto exit;
} }
if (PyUnicode_READY(arg) == -1) { if (PyUnicode_READY(arg) == -1) {
@ -819,10 +819,22 @@ sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
int depth = 0; int depth = 0;
if (!_PyArg_ParseStack(args, nargs, "|i:_getframe", if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
&depth)) {
goto exit; 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); return_value = sys__getframe_impl(module, depth);
exit: exit:
@ -872,10 +884,15 @@ sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *func; PyObject *func;
PyObject *funcargs; PyObject *funcargs;
if (!_PyArg_ParseStack(args, nargs, "OO!:call_tracing", if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
&func, &PyTuple_Type, &funcargs)) {
goto exit; 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); return_value = sys_call_tracing_impl(module, func, funcargs);
exit: exit:
@ -1029,4 +1046,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(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(). */ /* Format an error message generated by convertsimple(). */
void 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", if (iarg) {
fname, expected, PyErr_Format(PyExc_TypeError,
arg == Py_None ? "None" : arg->ob_type->tp_name); "%.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 * static const char *
@ -2416,13 +2426,12 @@ skipitem(const char **p_format, va_list *p_va, int flags)
} }
static int #undef _PyArg_CheckPositional
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;
int
_PyArg_CheckPositional(const char *name, Py_ssize_t nargs,
Py_ssize_t min, Py_ssize_t max)
{
assert(min >= 0); assert(min >= 0);
assert(min <= max); assert(min <= max);
@ -2460,6 +2469,20 @@ unpack_stack(PyObject *const *args, Py_ssize_t nargs, const char *name,
return 0; 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++) { for (i = 0; i < nargs; i++) {
o = va_arg(vargs, PyObject **); o = va_arg(vargs, PyObject **);
*o = args[i]; *o = args[i];

View file

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