bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)

This commit is contained in:
Serhiy Storchaka
2018-12-25 13:23:47 +02:00
committed by GitHub
parent 65ce60aef1
commit 32d96a2b5b
49 changed files with 1677 additions and 275 deletions

View File

@@ -66,6 +66,8 @@ PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
#define _PyArg_NoPositional(funcname, args) \
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, PyObject *);
#endif
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);

View File

@@ -201,9 +201,11 @@ test_PyBytesObject_converter(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyBytesObject *a;
if (!PyArg_Parse(arg, "S:test_PyBytesObject_converter", &a)) {
if (!PyBytes_Check(arg)) {
_PyArg_BadArgument("test_PyBytesObject_converter", "bytes", arg);
goto exit;
}
a = (PyBytesObject *)arg;
return_value = test_PyBytesObject_converter_impl(module, a);
exit:
@@ -212,7 +214,7 @@ exit:
static PyObject *
test_PyBytesObject_converter_impl(PyObject *module, PyBytesObject *a)
/*[clinic end generated code: output=8dbf43c604ced031 input=12b10c7cb5750400]*/
/*[clinic end generated code: output=fd69d6df4d26c853 input=12b10c7cb5750400]*/
/*[clinic input]
test_PyByteArrayObject_converter
@@ -239,9 +241,11 @@ test_PyByteArrayObject_converter(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyByteArrayObject *a;
if (!PyArg_Parse(arg, "Y:test_PyByteArrayObject_converter", &a)) {
if (!PyByteArray_Check(arg)) {
_PyArg_BadArgument("test_PyByteArrayObject_converter", "bytearray", arg);
goto exit;
}
a = (PyByteArrayObject *)arg;
return_value = test_PyByteArrayObject_converter_impl(module, a);
exit:
@@ -250,7 +254,7 @@ exit:
static PyObject *
test_PyByteArrayObject_converter_impl(PyObject *module, PyByteArrayObject *a)
/*[clinic end generated code: output=ade99fc6705e7d6e input=5a657da535d194ae]*/
/*[clinic end generated code: output=d309c909182c4183 input=5a657da535d194ae]*/
/*[clinic input]
test_unicode_converter
@@ -277,9 +281,14 @@ test_unicode_converter(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *a;
if (!PyArg_Parse(arg, "U:test_unicode_converter", &a)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("test_unicode_converter", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
a = arg;
return_value = test_unicode_converter_impl(module, a);
exit:
@@ -288,7 +297,7 @@ exit:
static PyObject *
test_unicode_converter_impl(PyObject *module, PyObject *a)
/*[clinic end generated code: output=504a2c8d00370adf input=aa33612df92aa9c5]*/
/*[clinic end generated code: output=ca603454e1f8f764 input=aa33612df92aa9c5]*/
/*[clinic input]
test_bool_converter
@@ -1027,7 +1036,8 @@ test_Py_complex_converter(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_complex a;
if (!PyArg_Parse(arg, "D:test_Py_complex_converter", &a)) {
a = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = test_Py_complex_converter_impl(module, a);
@@ -1038,7 +1048,7 @@ exit:
static PyObject *
test_Py_complex_converter_impl(PyObject *module, Py_complex a)
/*[clinic end generated code: output=27efb4ff772d6170 input=070f216a515beb79]*/
/*[clinic end generated code: output=c2ecbec2144ca540 input=070f216a515beb79]*/
/*[clinic input]
test_str_converter

View File

@@ -19,7 +19,13 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
@@ -50,7 +56,13 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "contiguous buffer", arg);
goto exit;
}
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
@@ -183,7 +195,13 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto_impl(self, &buffer);
@@ -214,7 +232,13 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto1", "contiguous buffer", arg);
goto exit;
}
return_value = _io__Buffered_readinto1_impl(self, &buffer);
@@ -390,7 +414,11 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
goto exit;
}
return_value = _io_BufferedWriter_write_impl(self, &buffer);
@@ -476,4 +504,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=cb4bf8d50533953b input=a9049054013a1b77]*/
/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/

View File

@@ -296,7 +296,13 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
goto exit;
}
return_value = _io_BytesIO_readinto_impl(self, &buffer);
@@ -444,4 +450,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=89538a941ae1267a input=a9049054013a1b77]*/
/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/

View File

@@ -156,7 +156,13 @@ _io_FileIO_readinto(fileio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
goto exit;
}
return_value = _io_FileIO_readinto_impl(self, &buffer);
@@ -245,7 +251,11 @@ _io_FileIO_write(fileio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &b)) {
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
goto exit;
}
return_value = _io_FileIO_write_impl(self, &b);
@@ -373,4 +383,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
/*[clinic end generated code: output=9d44e7035bce105d input=a9049054013a1b77]*/
/*[clinic end generated code: output=8be0ea9a5ac7aa43 input=a9049054013a1b77]*/

View File

@@ -250,9 +250,14 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *text;
if (!PyArg_Parse(arg, "U:write", &text)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("write", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
text = arg;
return_value = _io_TextIOWrapper_write_impl(self, text);
exit:
@@ -504,4 +509,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
/*[clinic end generated code: output=a811badd76bfe92e input=a9049054013a1b77]*/
/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/

View File

@@ -156,7 +156,13 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
PyErr_Clear();
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
goto exit;
}
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
@@ -255,7 +261,11 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &b)) {
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
goto exit;
}
return_value = _io__WindowsConsoleIO_write_impl(self, &b);
@@ -328,4 +338,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
/*[clinic end generated code: output=080af41338394b49 input=a9049054013a1b77]*/
/*[clinic end generated code: output=4337e8de65915a1e input=a9049054013a1b77]*/

View File

@@ -83,7 +83,7 @@ _sha3_shake_128_digest(SHA3object *self, PyObject *arg)
PyObject *return_value = NULL;
unsigned long length;
if (!PyArg_Parse(arg, "O&:digest", _PyLong_UnsignedLong_Converter, &length)) {
if (!_PyLong_UnsignedLong_Converter(arg, &length)) {
goto exit;
}
return_value = _sha3_shake_128_digest_impl(self, length);
@@ -110,7 +110,7 @@ _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg)
PyObject *return_value = NULL;
unsigned long length;
if (!PyArg_Parse(arg, "O&:hexdigest", _PyLong_UnsignedLong_Converter, &length)) {
if (!_PyLong_UnsignedLong_Converter(arg, &length)) {
goto exit;
}
return_value = _sha3_shake_128_hexdigest_impl(self, length);
@@ -118,4 +118,4 @@ _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=bf823532a7bffe68 input=a9049054013a1b77]*/
/*[clinic end generated code: output=5b3e99b9a96471e8 input=a9049054013a1b77]*/

View File

@@ -96,7 +96,7 @@ class cache_struct_converter(CConverter):
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=49957cca130ffb63]*/
static int cache_struct_converter(PyObject *, PyObject **);
static int cache_struct_converter(PyObject *, PyStructObject **);
#include "clinic/_struct.c.h"
@@ -2072,7 +2072,7 @@ PyTypeObject PyStructType = {
static PyObject *cache = NULL;
static int
cache_struct_converter(PyObject *fmt, PyObject **ptr)
cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
{
PyObject * s_object;
@@ -2091,7 +2091,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr)
s_object = PyDict_GetItem(cache, fmt);
if (s_object != NULL) {
Py_INCREF(s_object);
*ptr = s_object;
*ptr = (PyStructObject *)s_object;
return Py_CLEANUP_SUPPORTED;
}
@@ -2102,7 +2102,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr)
/* Attempt to cache the result */
if (PyDict_SetItem(cache, fmt, s_object) == -1)
PyErr_Clear();
*ptr = s_object;
*ptr = (PyStructObject *)s_object;
return Py_CLEANUP_SUPPORTED;
}
return 0;
@@ -2157,7 +2157,7 @@ pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
format = args[0];
if (!cache_struct_converter(format, &s_object)) {
if (!cache_struct_converter(format, (PyStructObject **)&s_object)) {
return NULL;
}
result = s_pack(s_object, args + 1, nargs - 1);
@@ -2185,7 +2185,7 @@ pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
format = args[0];
if (!cache_struct_converter(format, &s_object)) {
if (!cache_struct_converter(format, (PyStructObject **)&s_object)) {
return NULL;
}
result = s_pack_into(s_object, args + 1, nargs - 1);

View File

@@ -150,9 +150,11 @@ _multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoder
PyObject *return_value = NULL;
PyLongObject *statelong;
if (!PyArg_Parse(arg, "O!:setstate", &PyLong_Type, &statelong)) {
if (!PyLong_Check(arg)) {
_PyArg_BadArgument("setstate", "int", arg);
goto exit;
}
statelong = (PyLongObject *)arg;
return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
exit:
@@ -248,9 +250,11 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoder
PyObject *return_value = NULL;
PyObject *state;
if (!PyArg_Parse(arg, "O!:setstate", &PyTuple_Type, &state)) {
if (!PyTuple_Check(arg)) {
_PyArg_BadArgument("setstate", "tuple", arg);
goto exit;
}
state = arg;
return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
exit:
@@ -418,4 +422,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
/*[clinic end generated code: output=4c1dc8015ee5abb4 input=a9049054013a1b77]*/
/*[clinic end generated code: output=a94364d0965adf1d input=a9049054013a1b77]*/

View File

@@ -25,7 +25,11 @@ _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:compress", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg);
goto exit;
}
return_value = _bz2_BZ2Compressor_compress_impl(self, &data);
@@ -174,4 +178,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=e47f4255d265b07d input=a9049054013a1b77]*/
/*[clinic end generated code: output=8549cccdb82f57d9 input=a9049054013a1b77]*/

View File

@@ -33,7 +33,17 @@ _codecs_lookup(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *encoding;
if (!PyArg_Parse(arg, "s:lookup", &encoding)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("lookup", "str", arg);
goto exit;
}
Py_ssize_t encoding_length;
encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length);
if (encoding == NULL) {
goto exit;
}
if (strlen(encoding) != (size_t)encoding_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _codecs_lookup_impl(module, encoding);
@@ -138,7 +148,17 @@ _codecs__forget_codec(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *encoding;
if (!PyArg_Parse(arg, "s:_forget_codec", &encoding)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("_forget_codec", "str", arg);
goto exit;
}
Py_ssize_t encoding_length;
encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length);
if (encoding == NULL) {
goto exit;
}
if (strlen(encoding) != (size_t)encoding_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _codecs__forget_codec_impl(module, encoding);
@@ -1342,9 +1362,14 @@ _codecs_charmap_build(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *map;
if (!PyArg_Parse(arg, "U:charmap_build", &map)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("charmap_build", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
map = arg;
return_value = _codecs_charmap_build_impl(module, map);
exit:
@@ -1504,7 +1529,17 @@ _codecs_lookup_error(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *name;
if (!PyArg_Parse(arg, "s:lookup_error", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("lookup_error", "str", arg);
goto exit;
}
Py_ssize_t name_length;
name = PyUnicode_AsUTF8AndSize(arg, &name_length);
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _codecs_lookup_error_impl(module, name);
@@ -1536,4 +1571,4 @@ exit:
#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
#define _CODECS_CODE_PAGE_ENCODE_METHODDEF
#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
/*[clinic end generated code: output=d29fe7c0cb206812 input=a9049054013a1b77]*/
/*[clinic end generated code: output=c2d2b917b78a4c45 input=a9049054013a1b77]*/

View File

@@ -196,9 +196,11 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyCursesWindowObject *win;
if (!PyArg_Parse(arg, "O!:replace", &PyCursesWindow_Type, &win)) {
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
_PyArg_BadArgument("replace", (&PyCursesWindow_Type)->tp_name, arg);
goto exit;
}
win = (PyCursesWindowObject *)arg;
return_value = _curses_panel_panel_replace_impl(self, win);
exit:
@@ -268,9 +270,11 @@ _curses_panel_new_panel(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyCursesWindowObject *win;
if (!PyArg_Parse(arg, "O!:new_panel", &PyCursesWindow_Type, &win)) {
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
_PyArg_BadArgument("new_panel", (&PyCursesWindow_Type)->tp_name, arg);
goto exit;
}
win = (PyCursesWindowObject *)arg;
return_value = _curses_panel_new_panel_impl(module, win);
exit:
@@ -314,4 +318,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _curses_panel_update_panels_impl(module);
}
/*[clinic end generated code: output=66e49cb9726a638f input=a9049054013a1b77]*/
/*[clinic end generated code: output=4b211b4015e29100 input=a9049054013a1b77]*/

View File

@@ -273,7 +273,13 @@ _curses_window_attroff(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
long attr;
if (!PyArg_Parse(arg, "l:attroff", &attr)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = PyLong_AsLong(arg);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_attroff_impl(self, attr);
@@ -300,7 +306,13 @@ _curses_window_attron(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
long attr;
if (!PyArg_Parse(arg, "l:attron", &attr)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = PyLong_AsLong(arg);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_attron_impl(self, attr);
@@ -327,7 +339,13 @@ _curses_window_attrset(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
long attr;
if (!PyArg_Parse(arg, "l:attrset", &attr)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = PyLong_AsLong(arg);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_attrset_impl(self, attr);
@@ -1198,7 +1216,13 @@ _curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
int line;
if (!PyArg_Parse(arg, "i:is_linetouched", &line)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
line = _PyLong_AsInt(arg);
if (line == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_is_linetouched_impl(self, line);
@@ -1888,9 +1912,30 @@ _curses_color_content(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
short color_number;
if (!PyArg_Parse(arg, "h:color_content", &color_number)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(arg);
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;
}
}
return_value = _curses_color_content_impl(module, color_number);
exit:
@@ -1921,9 +1966,30 @@ _curses_color_pair(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
short color_number;
if (!PyArg_Parse(arg, "h:color_pair", &color_number)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(arg);
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;
}
}
return_value = _curses_color_pair_impl(module, color_number);
exit:
@@ -1956,7 +2022,13 @@ _curses_curs_set(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int visibility;
if (!PyArg_Parse(arg, "i:curs_set", &visibility)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
visibility = _PyLong_AsInt(arg);
if (visibility == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_curs_set_impl(module, visibility);
@@ -2030,7 +2102,13 @@ _curses_delay_output(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int ms;
if (!PyArg_Parse(arg, "i:delay_output", &ms)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
ms = _PyLong_AsInt(arg);
if (ms == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_delay_output_impl(module, ms);
@@ -2290,9 +2368,30 @@ _curses_halfdelay(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
unsigned char tenths;
if (!PyArg_Parse(arg, "b:halfdelay", &tenths)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(arg);
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
else if (ival < 0) {
PyErr_SetString(PyExc_OverflowError,
"unsigned byte integer is less than minimum");
goto exit;
}
else if (ival > UCHAR_MAX) {
PyErr_SetString(PyExc_OverflowError,
"unsigned byte integer is greater than maximum");
goto exit;
}
else {
tenths = (unsigned char) ival;
}
}
return_value = _curses_halfdelay_impl(module, tenths);
exit:
@@ -2376,7 +2475,13 @@ _curses_has_key(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int key;
if (!PyArg_Parse(arg, "i:has_key", &key)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
key = _PyLong_AsInt(arg);
if (key == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_has_key_impl(module, key);
@@ -2548,7 +2653,13 @@ _curses_intrflush(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int flag;
if (!PyArg_Parse(arg, "i:intrflush", &flag)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(arg);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_intrflush_impl(module, flag);
@@ -2634,7 +2745,13 @@ _curses_keyname(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int key;
if (!PyArg_Parse(arg, "i:keyname", &key)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
key = _PyLong_AsInt(arg);
if (key == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_keyname_impl(module, key);
@@ -2703,7 +2820,13 @@ _curses_meta(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int yes;
if (!PyArg_Parse(arg, "i:meta", &yes)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
yes = _PyLong_AsInt(arg);
if (yes == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_meta_impl(module, yes);
@@ -2739,7 +2862,13 @@ _curses_mouseinterval(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int interval;
if (!PyArg_Parse(arg, "i:mouseinterval", &interval)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
interval = _PyLong_AsInt(arg);
if (interval == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_mouseinterval_impl(module, interval);
@@ -2775,9 +2904,11 @@ _curses_mousemask(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
unsigned long newmask;
if (!PyArg_Parse(arg, "k:mousemask", &newmask)) {
if (!PyLong_Check(arg)) {
_PyArg_BadArgument("mousemask", "int", arg);
goto exit;
}
newmask = PyLong_AsUnsignedLongMask(arg);
return_value = _curses_mousemask_impl(module, newmask);
exit:
@@ -2807,7 +2938,13 @@ _curses_napms(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int ms;
if (!PyArg_Parse(arg, "i:napms", &ms)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
ms = _PyLong_AsInt(arg);
if (ms == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_napms_impl(module, ms);
@@ -3062,9 +3199,30 @@ _curses_pair_content(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
short pair_number;
if (!PyArg_Parse(arg, "h:pair_content", &pair_number)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
long ival = PyLong_AsLong(arg);
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;
}
}
return_value = _curses_pair_content_impl(module, pair_number);
exit:
@@ -3091,7 +3249,13 @@ _curses_pair_number(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int attr;
if (!PyArg_Parse(arg, "i:pair_number", &attr)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
attr = _PyLong_AsInt(arg);
if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_pair_number_impl(module, attr);
@@ -3511,7 +3675,17 @@ _curses_tigetflag(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *capname;
if (!PyArg_Parse(arg, "s:tigetflag", &capname)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetflag", "str", arg);
goto exit;
}
Py_ssize_t capname_length;
capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
if (capname == NULL) {
goto exit;
}
if (strlen(capname) != (size_t)capname_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _curses_tigetflag_impl(module, capname);
@@ -3544,7 +3718,17 @@ _curses_tigetnum(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *capname;
if (!PyArg_Parse(arg, "s:tigetnum", &capname)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetnum", "str", arg);
goto exit;
}
Py_ssize_t capname_length;
capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
if (capname == NULL) {
goto exit;
}
if (strlen(capname) != (size_t)capname_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _curses_tigetnum_impl(module, capname);
@@ -3577,7 +3761,17 @@ _curses_tigetstr(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *capname;
if (!PyArg_Parse(arg, "s:tigetstr", &capname)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("tigetstr", "str", arg);
goto exit;
}
Py_ssize_t capname_length;
capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
if (capname == NULL) {
goto exit;
}
if (strlen(capname) != (size_t)capname_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _curses_tigetstr_impl(module, capname);
@@ -3653,7 +3847,13 @@ _curses_typeahead(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int fd;
if (!PyArg_Parse(arg, "i:typeahead", &fd)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
fd = _PyLong_AsInt(arg);
if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_typeahead_impl(module, fd);
@@ -3727,7 +3927,13 @@ _curses_use_env(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int flag;
if (!PyArg_Parse(arg, "i:use_env", &flag)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flag = _PyLong_AsInt(arg);
if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_use_env_impl(module, flag);
@@ -3838,4 +4044,4 @@ _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
/*[clinic end generated code: output=177ad1d0b5586aaa input=a9049054013a1b77]*/
/*[clinic end generated code: output=a2bbced3c5d29d64 input=a9049054013a1b77]*/

View File

@@ -19,9 +19,11 @@ _elementtree_Element_append(ElementObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *subelement;
if (!PyArg_Parse(arg, "O!:append", &Element_Type, &subelement)) {
if (!PyObject_TypeCheck(arg, &Element_Type)) {
_PyArg_BadArgument("append", (&Element_Type)->tp_name, arg);
goto exit;
}
subelement = arg;
return_value = _elementtree_Element_append_impl(self, subelement);
exit:
@@ -79,9 +81,11 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *memo;
if (!PyArg_Parse(arg, "O!:__deepcopy__", &PyDict_Type, &memo)) {
if (!PyDict_Check(arg)) {
_PyArg_BadArgument("__deepcopy__", "dict", arg);
goto exit;
}
memo = arg;
return_value = _elementtree_Element___deepcopy___impl(self, memo);
exit:
@@ -507,9 +511,11 @@ _elementtree_Element_remove(ElementObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *subelement;
if (!PyArg_Parse(arg, "O!:remove", &Element_Type, &subelement)) {
if (!PyObject_TypeCheck(arg, &Element_Type)) {
_PyArg_BadArgument("remove", (&Element_Type)->tp_name, arg);
goto exit;
}
subelement = arg;
return_value = _elementtree_Element_remove_impl(self, subelement);
exit:
@@ -717,4 +723,4 @@ _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args,
exit:
return return_value;
}
/*[clinic end generated code: output=f1efdb511a5b027b input=a9049054013a1b77]*/
/*[clinic end generated code: output=398640585689c5ed input=a9049054013a1b77]*/

View File

@@ -25,7 +25,11 @@ _lzma_LZMACompressor_compress(Compressor *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:compress", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("compress", "contiguous buffer", arg);
goto exit;
}
return_value = _lzma_LZMACompressor_compress_impl(self, &data);
@@ -178,7 +182,13 @@ _lzma_is_check_supported(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int check_id;
if (!PyArg_Parse(arg, "i:is_check_supported", &check_id)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
check_id = _PyLong_AsInt(arg);
if (check_id == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _lzma_is_check_supported_impl(module, check_id);
@@ -207,7 +217,7 @@ _lzma__encode_filter_properties(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
lzma_filter filter = {LZMA_VLI_UNKNOWN, NULL};
if (!PyArg_Parse(arg, "O&:_encode_filter_properties", lzma_filter_converter, &filter)) {
if (!lzma_filter_converter(arg, &filter)) {
goto exit;
}
return_value = _lzma__encode_filter_properties_impl(module, filter);
@@ -256,4 +266,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=2acfd7c4b68530a6 input=a9049054013a1b77]*/
/*[clinic end generated code: output=df061bfc2067a90a input=a9049054013a1b77]*/

View File

@@ -47,7 +47,13 @@ _sre_ascii_iscased(PyObject *module, PyObject *arg)
int character;
int _return_value;
if (!PyArg_Parse(arg, "i:ascii_iscased", &character)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
character = _PyLong_AsInt(arg);
if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_ascii_iscased_impl(module, character);
@@ -78,7 +84,13 @@ _sre_unicode_iscased(PyObject *module, PyObject *arg)
int character;
int _return_value;
if (!PyArg_Parse(arg, "i:unicode_iscased", &character)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
character = _PyLong_AsInt(arg);
if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_unicode_iscased_impl(module, character);
@@ -109,7 +121,13 @@ _sre_ascii_tolower(PyObject *module, PyObject *arg)
int character;
int _return_value;
if (!PyArg_Parse(arg, "i:ascii_tolower", &character)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
character = _PyLong_AsInt(arg);
if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_ascii_tolower_impl(module, character);
@@ -140,7 +158,13 @@ _sre_unicode_tolower(PyObject *module, PyObject *arg)
int character;
int _return_value;
if (!PyArg_Parse(arg, "i:unicode_tolower", &character)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
character = _PyLong_AsInt(arg);
if (character == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = _sre_unicode_tolower_impl(module, character);
@@ -765,4 +789,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
{
return _sre_SRE_Scanner_search_impl(self);
}
/*[clinic end generated code: output=5edeca5ec36b5f34 input=a9049054013a1b77]*/
/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/

View File

@@ -36,7 +36,7 @@ _ssl__test_decode_cert(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *path;
if (!PyArg_Parse(arg, "O&:_test_decode_cert", PyUnicode_FSConverter, &path)) {
if (!PyUnicode_FSConverter(arg, &path)) {
goto exit;
}
return_value = _ssl__test_decode_cert_impl(module, path);
@@ -211,7 +211,11 @@ _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &b)) {
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLSocket_write_impl(self, &b);
@@ -400,7 +404,17 @@ _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
PyObject *return_value = NULL;
const char *cipherlist;
if (!PyArg_Parse(arg, "s:set_ciphers", &cipherlist)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("set_ciphers", "str", arg);
goto exit;
}
Py_ssize_t cipherlist_length;
cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length);
if (cipherlist == NULL) {
goto exit;
}
if (strlen(cipherlist) != (size_t)cipherlist_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist);
@@ -448,7 +462,11 @@ _ssl__SSLContext__set_npn_protocols(PySSLContext *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer protos = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:_set_npn_protocols", &protos)) {
if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_npn_protocols", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos);
@@ -480,7 +498,11 @@ _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer protos = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:_set_alpn_protocols", &protos)) {
if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&protos, 'C')) {
_PyArg_BadArgument("_set_alpn_protocols", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
@@ -823,7 +845,11 @@ _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer b = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:write", &b)) {
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&b, 'C')) {
_PyArg_BadArgument("write", "contiguous buffer", arg);
goto exit;
}
return_value = _ssl_MemoryBIO_write_impl(self, &b);
@@ -912,7 +938,13 @@ _ssl_RAND_bytes(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int n;
if (!PyArg_Parse(arg, "i:RAND_bytes", &n)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
n = _PyLong_AsInt(arg);
if (n == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _ssl_RAND_bytes_impl(module, n);
@@ -942,7 +974,13 @@ _ssl_RAND_pseudo_bytes(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int n;
if (!PyArg_Parse(arg, "i:RAND_pseudo_bytes", &n)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
n = _PyLong_AsInt(arg);
if (n == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _ssl_RAND_pseudo_bytes_impl(module, n);
@@ -995,7 +1033,7 @@ _ssl_RAND_egd(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *path;
if (!PyArg_Parse(arg, "O&:RAND_egd", PyUnicode_FSConverter, &path)) {
if (!PyUnicode_FSConverter(arg, &path)) {
goto exit;
}
return_value = _ssl_RAND_egd_impl(module, path);
@@ -1078,7 +1116,13 @@ _ssl_nid2obj(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int nid;
if (!PyArg_Parse(arg, "i:nid2obj", &nid)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
nid = _PyLong_AsInt(arg);
if (nid == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _ssl_nid2obj_impl(module, nid);
@@ -1193,4 +1237,4 @@ exit:
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
/*[clinic end generated code: output=d87f783224be8fca input=a9049054013a1b77]*/
/*[clinic end generated code: output=c2dca2ef4cbef4e2 input=a9049054013a1b77]*/

View File

@@ -57,7 +57,11 @@ Struct_unpack(PyStructObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:unpack", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("unpack", "contiguous buffer", arg);
goto exit;
}
return_value = Struct_unpack_impl(self, &buffer);
@@ -166,7 +170,7 @@ calcsize(PyObject *module, PyObject *arg)
PyStructObject *s_object = NULL;
Py_ssize_t _return_value;
if (!PyArg_Parse(arg, "O&:calcsize", cache_struct_converter, &s_object)) {
if (!cache_struct_converter(arg, &s_object)) {
goto exit;
}
_return_value = calcsize_impl(module, s_object);
@@ -303,4 +307,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=a73b0453174e4b51 input=a9049054013a1b77]*/
/*[clinic end generated code: output=01516bea2641fe01 input=a9049054013a1b77]*/

View File

@@ -19,7 +19,17 @@ _tkinter_tkapp_eval(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *script;
if (!PyArg_Parse(arg, "s:eval", &script)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("eval", "str", arg);
goto exit;
}
Py_ssize_t script_length;
script = PyUnicode_AsUTF8AndSize(arg, &script_length);
if (script == NULL) {
goto exit;
}
if (strlen(script) != (size_t)script_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_eval_impl(self, script);
@@ -45,7 +55,17 @@ _tkinter_tkapp_evalfile(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *fileName;
if (!PyArg_Parse(arg, "s:evalfile", &fileName)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("evalfile", "str", arg);
goto exit;
}
Py_ssize_t fileName_length;
fileName = PyUnicode_AsUTF8AndSize(arg, &fileName_length);
if (fileName == NULL) {
goto exit;
}
if (strlen(fileName) != (size_t)fileName_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_evalfile_impl(self, fileName);
@@ -71,7 +91,17 @@ _tkinter_tkapp_record(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *script;
if (!PyArg_Parse(arg, "s:record", &script)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("record", "str", arg);
goto exit;
}
Py_ssize_t script_length;
script = PyUnicode_AsUTF8AndSize(arg, &script_length);
if (script == NULL) {
goto exit;
}
if (strlen(script) != (size_t)script_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_record_impl(self, script);
@@ -97,7 +127,17 @@ _tkinter_tkapp_adderrorinfo(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *msg;
if (!PyArg_Parse(arg, "s:adderrorinfo", &msg)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("adderrorinfo", "str", arg);
goto exit;
}
Py_ssize_t msg_length;
msg = PyUnicode_AsUTF8AndSize(arg, &msg_length);
if (msg == NULL) {
goto exit;
}
if (strlen(msg) != (size_t)msg_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_adderrorinfo_impl(self, msg);
@@ -147,7 +187,17 @@ _tkinter_tkapp_exprstring(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *s;
if (!PyArg_Parse(arg, "s:exprstring", &s)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprstring", "str", arg);
goto exit;
}
Py_ssize_t s_length;
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
if (s == NULL) {
goto exit;
}
if (strlen(s) != (size_t)s_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprstring_impl(self, s);
@@ -173,7 +223,17 @@ _tkinter_tkapp_exprlong(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *s;
if (!PyArg_Parse(arg, "s:exprlong", &s)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprlong", "str", arg);
goto exit;
}
Py_ssize_t s_length;
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
if (s == NULL) {
goto exit;
}
if (strlen(s) != (size_t)s_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprlong_impl(self, s);
@@ -199,7 +259,17 @@ _tkinter_tkapp_exprdouble(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *s;
if (!PyArg_Parse(arg, "s:exprdouble", &s)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprdouble", "str", arg);
goto exit;
}
Py_ssize_t s_length;
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
if (s == NULL) {
goto exit;
}
if (strlen(s) != (size_t)s_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprdouble_impl(self, s);
@@ -225,7 +295,17 @@ _tkinter_tkapp_exprboolean(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *s;
if (!PyArg_Parse(arg, "s:exprboolean", &s)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("exprboolean", "str", arg);
goto exit;
}
Py_ssize_t s_length;
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
if (s == NULL) {
goto exit;
}
if (strlen(s) != (size_t)s_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_exprboolean_impl(self, s);
@@ -296,7 +376,17 @@ _tkinter_tkapp_deletecommand(TkappObject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *name;
if (!PyArg_Parse(arg, "s:deletecommand", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("deletecommand", "str", arg);
goto exit;
}
Py_ssize_t name_length;
name = PyUnicode_AsUTF8AndSize(arg, &name_length);
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _tkinter_tkapp_deletecommand_impl(self, name);
@@ -594,7 +684,13 @@ _tkinter_setbusywaitinterval(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int new_val;
if (!PyArg_Parse(arg, "i:setbusywaitinterval", &new_val)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
new_val = _PyLong_AsInt(arg);
if (new_val == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _tkinter_setbusywaitinterval_impl(module, new_val);
@@ -638,4 +734,4 @@ exit:
#ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
#endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */
/*[clinic end generated code: output=a9d45a90cde94980 input=a9049054013a1b77]*/
/*[clinic end generated code: output=d84b0e794824c511 input=a9049054013a1b77]*/

Some files were not shown because too many files have changed in this diff Show More