Commit 32d96a2b authored by Serhiy Storchaka's avatar Serhiy Storchaka Committed by GitHub

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

parent 65ce60ae
......@@ -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);
......
......@@ -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
......
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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);
......
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
This diff is collapsed.
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -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]*/
......@@ -19,7 +19,8 @@ _winapi_Overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *arg)
PyObject *return_value = NULL;
int wait;
if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait)) {
wait = PyObject_IsTrue(arg);
if (wait < 0) {
goto exit;
}
return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait);
......@@ -944,4 +945,4 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
exit:
return return_value;
}
/*[clinic end generated code: output=145d0d362167c1b1 input=a9049054013a1b77]*/
/*[clinic end generated code: output=5063c84b2d125488 input=a9049054013a1b77]*/
......@@ -278,8 +278,22 @@ array_array_fromstring(arrayobject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "s*:fromstring", &buffer)) {
goto exit;
if (PyUnicode_Check(arg)) {
Py_ssize_t len;
const char *ptr = PyUnicode_AsUTF8AndSize(arg, &len);
if (ptr == NULL) {
goto exit;
}
PyBuffer_FillInfo(&buffer, arg, (void *)ptr, len, 1, 0);
}
else { /* any bytes-like object */
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("fromstring", "contiguous buffer", arg);
goto exit;
}
}
return_value = array_array_fromstring_impl(self, &buffer);
......@@ -310,7 +324,11 @@ array_array_frombytes(arrayobject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer buffer = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:frombytes", &buffer)) {
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
_PyArg_BadArgument("frombytes", "contiguous buffer", arg);
goto exit;
}
return_value = array_array_frombytes_impl(self, &buffer);
......@@ -505,4 +523,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
/*[clinic end generated code: output=3d2bb1aa81541cbd input=a9049054013a1b77]*/
/*[clinic end generated code: output=15da19d2ece09d22 input=a9049054013a1b77]*/
......@@ -20,7 +20,7 @@ binascii_a2b_uu(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "O&:a2b_uu", ascii_buffer_converter, &data)) {
if (!ascii_buffer_converter(arg, &data)) {
goto exit;
}
return_value = binascii_a2b_uu_impl(module, &data);
......@@ -87,7 +87,7 @@ binascii_a2b_base64(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "O&:a2b_base64", ascii_buffer_converter, &data)) {
if (!ascii_buffer_converter(arg, &data)) {
goto exit;
}
return_value = binascii_a2b_base64_impl(module, &data);
......@@ -154,7 +154,7 @@ binascii_a2b_hqx(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "O&:a2b_hqx", ascii_buffer_converter, &data)) {
if (!ascii_buffer_converter(arg, &data)) {
goto exit;
}
return_value = binascii_a2b_hqx_impl(module, &data);
......@@ -185,7 +185,11 @@ binascii_rlecode_hqx(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:rlecode_hqx", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("rlecode_hqx", "contiguous buffer", arg);
goto exit;
}
return_value = binascii_rlecode_hqx_impl(module, &data);
......@@ -217,7 +221,11 @@ binascii_b2a_hqx(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:b2a_hqx", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hqx", "contiguous buffer", arg);
goto exit;
}
return_value = binascii_b2a_hqx_impl(module, &data);
......@@ -249,7 +257,11 @@ binascii_rledecode_hqx(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:rledecode_hqx", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("rledecode_hqx", "contiguous buffer", arg);
goto exit;
}
return_value = binascii_rledecode_hqx_impl(module, &data);
......@@ -362,7 +374,11 @@ binascii_b2a_hex(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:b2a_hex", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("b2a_hex", "contiguous buffer", arg);
goto exit;
}
return_value = binascii_b2a_hex_impl(module, &data);
......@@ -396,7 +412,11 @@ binascii_hexlify(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:hexlify", &data)) {
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&data, 'C')) {
_PyArg_BadArgument("hexlify", "contiguous buffer", arg);
goto exit;
}
return_value = binascii_hexlify_impl(module, &data);
......@@ -431,7 +451,7 @@ binascii_a2b_hex(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer hexstr = {NULL, NULL};
if (!PyArg_Parse(arg, "O&:a2b_hex", ascii_buffer_converter, &hexstr)) {
if (!ascii_buffer_converter(arg, &hexstr)) {
goto exit;
}
return_value = binascii_a2b_hex_impl(module, &hexstr);
......@@ -464,7 +484,7 @@ binascii_unhexlify(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer hexstr = {NULL, NULL};
if (!PyArg_Parse(arg, "O&:unhexlify", ascii_buffer_converter, &hexstr)) {
if (!ascii_buffer_converter(arg, &hexstr)) {
goto exit;
}
return_value = binascii_unhexlify_impl(module, &hexstr);
......@@ -554,4 +574,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=3f45e15ce8b563b7 input=a9049054013a1b77]*/
/*[clinic end generated code: output=8ff0cb5717b15d1b input=a9049054013a1b77]*/
......@@ -21,7 +21,8 @@ cmath_acos(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:acos", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -63,7 +64,8 @@ cmath_acosh(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:acosh", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -105,7 +107,8 @@ cmath_asin(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:asin", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -147,7 +150,8 @@ cmath_asinh(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:asinh", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -189,7 +193,8 @@ cmath_atan(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:atan", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -231,7 +236,8 @@ cmath_atanh(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:atanh", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -273,7 +279,8 @@ cmath_cos(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:cos", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -315,7 +322,8 @@ cmath_cosh(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:cosh", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -357,7 +365,8 @@ cmath_exp(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:exp", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -399,7 +408,8 @@ cmath_log10(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:log10", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -441,7 +451,8 @@ cmath_sin(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:sin", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -483,7 +494,8 @@ cmath_sinh(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:sinh", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -525,7 +537,8 @@ cmath_sqrt(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:sqrt", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -567,7 +580,8 @@ cmath_tan(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:tan", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -609,7 +623,8 @@ cmath_tanh(PyObject *module, PyObject *arg)
Py_complex z;
Py_complex _return_value;
if (!PyArg_Parse(arg, "D:tanh", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
/* modifications for z */
......@@ -681,7 +696,8 @@ cmath_phase(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_complex z;
if (!PyArg_Parse(arg, "D:phase", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = cmath_phase_impl(module, z);
......@@ -710,7 +726,8 @@ cmath_polar(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_complex z;
if (!PyArg_Parse(arg, "D:polar", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = cmath_polar_impl(module, z);
......@@ -766,7 +783,8 @@ cmath_isfinite(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_complex z;
if (!PyArg_Parse(arg, "D:isfinite", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = cmath_isfinite_impl(module, z);
......@@ -793,7 +811,8 @@ cmath_isnan(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_complex z;
if (!PyArg_Parse(arg, "D:isnan", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = cmath_isnan_impl(module, z);
......@@ -820,7 +839,8 @@ cmath_isinf(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_complex z;
if (!PyArg_Parse(arg, "D:isinf", &z)) {
z = PyComplex_AsCComplex(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = cmath_isinf_impl(module, z);
......@@ -882,4 +902,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
exit:
return return_value;
}
/*[clinic end generated code: output=17f6f65a229b1ef9 input=a9049054013a1b77]*/
/*[clinic end generated code: output=50a105aa2bc5308f input=a9049054013a1b77]*/
......@@ -136,7 +136,13 @@ gc_set_debug(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int flags;
if (!PyArg_Parse(arg, "i:set_debug", &flags)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
flags = _PyLong_AsInt(arg);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = gc_set_debug_impl(module, flags);
......@@ -325,4 +331,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))
exit:
return return_value;
}
/*[clinic end generated code: output=ba67a1ab58780485 input=a9049054013a1b77]*/
/*[clinic end generated code: output=5aa5fdc259503d5f input=a9049054013a1b77]*/
......@@ -108,7 +108,8 @@ math_frexp(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:frexp", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_frexp_impl(module, x);
......@@ -168,7 +169,8 @@ math_modf(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:modf", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_modf_impl(module, x);
......@@ -352,7 +354,8 @@ math_degrees(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:degrees", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_degrees_impl(module, x);
......@@ -379,7 +382,8 @@ math_radians(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:radians", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_radians_impl(module, x);
......@@ -406,7 +410,8 @@ math_isfinite(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:isfinite", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_isfinite_impl(module, x);
......@@ -433,7 +438,8 @@ math_isnan(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:isnan", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_isnan_impl(module, x);
......@@ -460,7 +466,8 @@ math_isinf(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
double x;
if (!PyArg_Parse(arg, "d:isinf", &x)) {
x = PyFloat_AsDouble(arg);
if (PyErr_Occurred()) {
goto exit;
}
return_value = math_isinf_impl(module, x);
......@@ -523,4 +530,4 @@ math_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
exit:
return return_value;
}
/*[clinic end generated code: output=8b1709a71e5fb855 input=a9049054013a1b77]*/
/*[clinic end generated code: output=da4b9940a5cb0188 input=a9049054013a1b77]*/
This diff is collapsed.
......@@ -33,9 +33,14 @@ pwd_getpwnam(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:getpwnam", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("getpwnam", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
name = arg;
return_value = pwd_getpwnam_impl(module, name);
exit:
......@@ -69,4 +74,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef PWD_GETPWALL_METHODDEF
#define PWD_GETPWALL_METHODDEF
#endif /* !defined(PWD_GETPWALL_METHODDEF) */
/*[clinic end generated code: output=3c93120d6dd86905 input=a9049054013a1b77]*/
/*[clinic end generated code: output=9e86e23d6ad9cd08 input=a9049054013a1b77]*/
......@@ -61,7 +61,17 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
PyObject *return_value = NULL;
const char *base;
if (!PyArg_Parse(arg, "s:SetBase", &base)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("SetBase", "str", arg);
goto exit;
}
Py_ssize_t base_length;
base = PyUnicode_AsUTF8AndSize(arg, &base_length);
if (base == NULL) {
goto exit;
}
if (strlen(base) != (size_t)base_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = pyexpat_xmlparser_SetBase_impl(self, base);
......@@ -163,7 +173,13 @@ pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
PyObject *return_value = NULL;
int flag;
if (!PyArg_Parse(arg, "i:SetParamEntityParsing", &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 = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
......@@ -260,7 +276,13 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
long code;
if (!PyArg_Parse(arg, "l:ErrorString", &code)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
code = PyLong_AsLong(arg);
if (code == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = pyexpat_ErrorString_impl(module, code);
......@@ -272,4 +294,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
/*[clinic end generated code: output=c390207761c679d3 input=a9049054013a1b77]*/
/*[clinic end generated code: output=d3750256eb0da1cb input=a9049054013a1b77]*/
......@@ -19,7 +19,13 @@ resource_getrusage(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int who;
if (!PyArg_Parse(arg, "i:getrusage", &who)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
who = _PyLong_AsInt(arg);
if (who == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = resource_getrusage_impl(module, who);
......@@ -45,7 +51,13 @@ resource_getrlimit(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int resource;
if (!PyArg_Parse(arg, "i:getrlimit", &resource)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
resource = _PyLong_AsInt(arg);
if (resource == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = resource_getrlimit_impl(module, resource);
......@@ -157,4 +169,4 @@ exit:
#ifndef RESOURCE_PRLIMIT_METHODDEF
#define RESOURCE_PRLIMIT_METHODDEF
#endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */
/*[clinic end generated code: output=637ed2c42bde5ca6 input=a9049054013a1b77]*/
/*[clinic end generated code: output=b16a9149639081fd input=a9049054013a1b77]*/
......@@ -153,7 +153,7 @@ select_poll_unregister(pollObject *self, PyObject *arg)
PyObject *return_value = NULL;
int fd;
if (!PyArg_Parse(arg, "O&:unregister", fildes_converter, &fd)) {
if (!fildes_converter(arg, &fd)) {
goto exit;
}
return_value = select_poll_unregister_impl(self, fd);
......@@ -300,7 +300,7 @@ select_devpoll_unregister(devpollObject *self, PyObject *arg)
PyObject *return_value = NULL;
int fd;
if (!PyArg_Parse(arg, "O&:unregister", fildes_converter, &fd)) {
if (!fildes_converter(arg, &fd)) {
goto exit;
}
return_value = select_devpoll_unregister_impl(self, fd);
......@@ -550,7 +550,13 @@ select_epoll_fromfd(PyTypeObject *type, PyObject *arg)
PyObject *return_value = NULL;
int fd;
if (!PyArg_Parse(arg, "i:fromfd", &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 = select_epoll_fromfd_impl(type, fd);
......@@ -893,7 +899,13 @@ select_kqueue_fromfd(PyTypeObject *type, PyObject *arg)
PyObject *return_value = NULL;
int fd;
if (!PyArg_Parse(arg, "i:fromfd", &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 = select_kqueue_fromfd_impl(type, fd);
......@@ -1047,4 +1059,4 @@ exit:
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
#define SELECT_KQUEUE_CONTROL_METHODDEF
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
/*[clinic end generated code: output=04c4019eb5a4d464 input=a9049054013a1b77]*/
/*[clinic end generated code: output=122a49f131cdd9d9 input=a9049054013a1b77]*/
......@@ -23,7 +23,13 @@ signal_alarm(PyObject *module, PyObject *arg)
int seconds;
long _return_value;
if (!PyArg_Parse(arg, "i:alarm", &seconds)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
seconds = _PyLong_AsInt(arg);
if (seconds == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = signal_alarm_impl(module, seconds);
......@@ -120,7 +126,13 @@ signal_getsignal(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int signalnum;
if (!PyArg_Parse(arg, "i:getsignal", &signalnum)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
signalnum = _PyLong_AsInt(arg);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_getsignal_impl(module, signalnum);
......@@ -150,7 +162,13 @@ signal_strsignal(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int signalnum;
if (!PyArg_Parse(arg, "i:strsignal", &signalnum)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
signalnum = _PyLong_AsInt(arg);
if (signalnum == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_strsignal_impl(module, signalnum);
......@@ -255,7 +273,13 @@ signal_getitimer(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int which;
if (!PyArg_Parse(arg, "i:getitimer", &which)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
which = _PyLong_AsInt(arg);
if (which == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = signal_getitimer_impl(module, which);
......@@ -348,7 +372,7 @@ signal_sigwait(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
sigset_t sigset;
if (!PyArg_Parse(arg, "O&:sigwait", _Py_Sigset_Converter, &sigset)) {
if (!_Py_Sigset_Converter(arg, &sigset)) {
goto exit;
}
return_value = signal_sigwait_impl(module, sigset);
......@@ -406,7 +430,7 @@ signal_sigwaitinfo(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
sigset_t sigset;
if (!PyArg_Parse(arg, "O&:sigwaitinfo", _Py_Sigset_Converter, &sigset)) {
if (!_Py_Sigset_Converter(arg, &sigset)) {
goto exit;
}
return_value = signal_sigwaitinfo_impl(module, sigset);
......@@ -534,4 +558,4 @@ exit:
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
#define SIGNAL_PTHREAD_KILL_METHODDEF
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
/*[clinic end generated code: output=fa0040750f4c1fcb input=a9049054013a1b77]*/
/*[clinic end generated code: output=4ed8c36860f9f577 input=a9049054013a1b77]*/
......@@ -24,9 +24,14 @@ spwd_getspnam(PyObject *module, PyObject *arg_)
PyObject *return_value = NULL;
PyObject *arg;
if (!PyArg_Parse(arg_, "U:getspnam", &arg)) {
if (!PyUnicode_Check(arg_)) {
_PyArg_BadArgument("getspnam", "str", arg_);
goto exit;
}
if (PyUnicode_READY(arg_) == -1) {
goto exit;
}
arg = arg_;
return_value = spwd_getspnam_impl(module, arg);
exit:
......@@ -66,4 +71,4 @@ spwd_getspall(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef SPWD_GETSPALL_METHODDEF
#define SPWD_GETSPALL_METHODDEF
#endif /* !defined(SPWD_GETSPALL_METHODDEF) */
/*[clinic end generated code: output=07cd8af0afd77fe7 input=a9049054013a1b77]*/
/*[clinic end generated code: output=44a7c196d4b48f4e input=a9049054013a1b77]*/
......@@ -121,9 +121,18 @@ unicodedata_UCD_category(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
int chr;
if (!PyArg_Parse(arg, "C:category", &chr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("category", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("category", "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
return_value = unicodedata_UCD_category_impl(self, chr);
exit:
......@@ -150,9 +159,18 @@ unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
int chr;
if (!PyArg_Parse(arg, "C:bidirectional", &chr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("bidirectional", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("bidirectional", "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
return_value = unicodedata_UCD_bidirectional_impl(self, chr);
exit:
......@@ -180,9 +198,18 @@ unicodedata_UCD_combining(PyObject *self, PyObject *arg)
int chr;
int _return_value;
if (!PyArg_Parse(arg, "C:combining", &chr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("combining", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("combining", "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
_return_value = unicodedata_UCD_combining_impl(self, chr);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
......@@ -215,9 +242,18 @@ unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
int chr;
int _return_value;
if (!PyArg_Parse(arg, "C:mirrored", &chr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("mirrored", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("mirrored", "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
_return_value = unicodedata_UCD_mirrored_impl(self, chr);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
......@@ -246,9 +282,18 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
int chr;
if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("east_asian_width", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("east_asian_width", "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
exit:
......@@ -275,9 +320,18 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
int chr;
if (!PyArg_Parse(arg, "C:decomposition", &chr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("decomposition", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("decomposition", "a unicode character", arg);
goto exit;
}
chr = PyUnicode_READ_CHAR(arg, 0);
return_value = unicodedata_UCD_decomposition_impl(self, chr);
exit:
......@@ -411,4 +465,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=67f474927be668bf input=a9049054013a1b77]*/
/*[clinic end generated code: output=709241b99d010896 input=a9049054013a1b77]*/
......@@ -215,7 +215,11 @@ zlib_Compress_compress(compobject *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 = zlib_Compress_compress_impl(self, &data);
......@@ -553,4 +557,4 @@ exit:
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
/*[clinic end generated code: output=e721c15e7af2d2fd input=a9049054013a1b77]*/
/*[clinic end generated code: output=bea1e3c64573d9fd input=a9049054013a1b77]*/
......@@ -354,7 +354,7 @@ bytearray_append(PyByteArrayObject *self, PyObject *arg)
PyObject *return_value = NULL;
int item;
if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item)) {
if (!_getbytevalue(arg, &item)) {
goto exit;
}
return_value = bytearray_append_impl(self, item);
......@@ -430,7 +430,7 @@ bytearray_remove(PyByteArrayObject *self, PyObject *arg)
PyObject *return_value = NULL;
int value;
if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value)) {
if (!_getbytevalue(arg, &value)) {
goto exit;
}
return_value = bytearray_remove_impl(self, value);
......@@ -640,9 +640,14 @@ bytearray_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *return_value = NULL;
PyObject *string;
if (!PyArg_Parse(arg, "U:fromhex", &string)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
string = arg;
return_value = bytearray_fromhex_impl(type, string);
exit:
......@@ -712,4 +717,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
/*[clinic end generated code: output=b88bb192dddca6e1 input=a9049054013a1b77]*/
/*[clinic end generated code: output=cd3e13a1905a473c input=a9049054013a1b77]*/
......@@ -66,7 +66,11 @@ bytes_partition(PyBytesObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:partition", &sep)) {
if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("partition", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_partition_impl(self, &sep);
......@@ -105,7 +109,11 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:rpartition", &sep)) {
if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&sep, 'C')) {
_PyArg_BadArgument("rpartition", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_rpartition_impl(self, &sep);
......@@ -491,12 +499,17 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
PyObject *return_value = NULL;
PyObject *string;
if (!PyArg_Parse(arg, "U:fromhex", &string)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("fromhex", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
string = arg;
return_value = bytes_fromhex_impl(type, string);
exit:
return return_value;
}
/*[clinic end generated code: output=07b33ac65362301b input=a9049054013a1b77]*/
/*[clinic end generated code: output=dc9aa04f0007ab11 input=a9049054013a1b77]*/
......@@ -228,7 +228,17 @@ float___getformat__(PyTypeObject *type, PyObject *arg)
PyObject *return_value = NULL;
const char *typestr;
if (!PyArg_Parse(arg, "s:__getformat__", &typestr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__getformat__", "str", arg);
goto exit;
}
Py_ssize_t typestr_length;
typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length);
if (typestr == NULL) {
goto exit;
}
if (strlen(typestr) != (size_t)typestr_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = float___getformat___impl(type, typestr);
......@@ -297,12 +307,17 @@ float___format__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *format_spec;
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
format_spec = arg;
return_value = float___format___impl(self, format_spec);
exit:
return return_value;
}
/*[clinic end generated code: output=091dd499f5386a6c input=a9049054013a1b77]*/
/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/
......@@ -58,9 +58,14 @@ int___format__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *format_spec;
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
format_spec = arg;
return_value = int___format___impl(self, format_spec);
exit:
......@@ -239,4 +244,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb
exit:
return return_value;
}
/*[clinic end generated code: output=403ccd096555fd1e input=a9049054013a1b77]*/
/*[clinic end generated code: output=7436b5f4decdcf9d input=a9049054013a1b77]*/
......@@ -166,7 +166,13 @@ object___reduce_ex__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
int protocol;
if (!PyArg_Parse(arg, "i:__reduce_ex__", &protocol)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
protocol = _PyLong_AsInt(arg);
if (protocol == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = object___reduce_ex___impl(self, protocol);
......@@ -193,9 +199,14 @@ object___format__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *format_spec;
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
format_spec = arg;
return_value = object___format___impl(self, format_spec);
exit:
......@@ -237,4 +248,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return object___dir___impl(self);
}
/*[clinic end generated code: output=8c4c856859564eaa input=a9049054013a1b77]*/
/*[clinic end generated code: output=09f3453839e60136 input=a9049054013a1b77]*/
......@@ -898,9 +898,23 @@ unicode_zfill(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_ssize_t width;
if (!PyArg_Parse(arg, "n:zfill", &width)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(arg);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
return_value = unicode_zfill_impl(self, width);
exit:
......@@ -925,9 +939,14 @@ unicode___format__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *format_spec;
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
format_spec = arg;
return_value = unicode___format___impl(self, format_spec);
exit:
......@@ -951,4 +970,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return unicode_sizeof_impl(self);
}
/*[clinic end generated code: output=d323802b67bfc6d8 input=a9049054013a1b77]*/
/*[clinic end generated code: output=ff6acd5abd1998eb input=a9049054013a1b77]*/
......@@ -147,12 +147,26 @@ stringlib_zfill(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
Py_ssize_t width;
if (!PyArg_Parse(arg, "n:zfill", &width)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
{
Py_ssize_t ival = -1;
PyObject *iobj = PyNumber_Index(arg);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
}
if (ival == -1 && PyErr_Occurred()) {
goto exit;
}
width = ival;
}
return_value = stringlib_zfill_impl(self, width);
exit:
return return_value;
}
/*[clinic end generated code: output=d09ba158d470566e input=a9049054013a1b77]*/
/*[clinic end generated code: output=bf2ef501639e1190 input=a9049054013a1b77]*/
......@@ -158,7 +158,13 @@ msvcrt_get_osfhandle(PyObject *module, PyObject *arg)
int fd;
void *_return_value;
if (!PyArg_Parse(arg, "i:get_osfhandle", &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 = msvcrt_get_osfhandle_impl(module, fd);
......@@ -319,7 +325,14 @@ msvcrt_putch(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
char char_value;
if (!PyArg_Parse(arg, "c:putch", &char_value)) {
if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
char_value = PyBytes_AS_STRING(arg)[0];
}
else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
char_value = PyByteArray_AS_STRING(arg)[0];
}
else {
_PyArg_BadArgument("putch", "a byte string of length 1", arg);
goto exit;
}
return_value = msvcrt_putch_impl(module, char_value);
......@@ -346,9 +359,18 @@ msvcrt_putwch(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int unicode_char;
if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("putwch", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("putwch", "a unicode character", arg);
goto exit;
}
unicode_char = PyUnicode_READ_CHAR(arg, 0);
return_value = msvcrt_putwch_impl(module, unicode_char);
exit:
......@@ -377,7 +399,14 @@ msvcrt_ungetch(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
char char_value;
if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
char_value = PyBytes_AS_STRING(arg)[0];
}
else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
char_value = PyByteArray_AS_STRING(arg)[0];
}
else {
_PyArg_BadArgument("ungetch", "a byte string of length 1", arg);
goto exit;
}
return_value = msvcrt_ungetch_impl(module, char_value);
......@@ -404,9 +433,18 @@ msvcrt_ungetwch(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int unicode_char;
if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("ungetwch", "a unicode character", arg);
goto exit;
}
if (PyUnicode_READY(arg)) {
goto exit;
}
if (PyUnicode_GET_LENGTH(arg) != 1) {
_PyArg_BadArgument("ungetwch", "a unicode character", arg);
goto exit;
}
unicode_char = PyUnicode_READ_CHAR(arg, 0);
return_value = msvcrt_ungetwch_impl(module, unicode_char);
exit:
......@@ -516,7 +554,13 @@ msvcrt_set_error_mode(PyObject *module, PyObject *arg)
int mode;
long _return_value;
if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = _PyLong_AsInt(arg);
if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = msvcrt_set_error_mode_impl(module, mode);
......@@ -549,7 +593,13 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
unsigned int mode;
if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
mode = (unsigned int)PyLong_AsUnsignedLongMask(arg);
if (mode == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
return_value = msvcrt_SetErrorMode_impl(module, mode);
......@@ -569,4 +619,4 @@ exit:
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
#define MSVCRT_SET_ERROR_MODE_METHODDEF
#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
/*[clinic end generated code: output=632089ff9236ac77 input=a9049054013a1b77]*/
/*[clinic end generated code: output=2530b4ff248563b4 input=a9049054013a1b77]*/
......@@ -541,7 +541,7 @@ winreg_FlushKey(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
HKEY key;
if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) {
if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_FlushKey_impl(module, key);
......@@ -734,7 +734,7 @@ winreg_QueryInfoKey(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
HKEY key;
if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) {
if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_QueryInfoKey_impl(module, key);
......@@ -1021,7 +1021,7 @@ winreg_DisableReflectionKey(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
HKEY key;
if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) {
if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_DisableReflectionKey_impl(module, key);
......@@ -1055,7 +1055,7 @@ winreg_EnableReflectionKey(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
HKEY key;
if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) {
if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_EnableReflectionKey_impl(module, key);
......@@ -1087,7 +1087,7 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
HKEY key;
if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) {
if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_QueryReflectionKey_impl(module, key);
......@@ -1095,4 +1095,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
exit:
return return_value;
}
/*[clinic end generated code: output=ff2cc1951ab1a56c input=a9049054013a1b77]*/
/*[clinic end generated code: output=82bd56c524c6c3dd input=a9049054013a1b77]*/
......@@ -122,7 +122,13 @@ builtin_chr(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int i;
if (!PyArg_Parse(arg, "i:chr", &i)) {
if (PyFloat_Check(arg)) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
i = _PyLong_AsInt(arg);
if (i == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = builtin_chr_impl(module, i);
......@@ -711,4 +717,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=fa8d97ac8695363b input=a9049054013a1b77]*/
/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/
......@@ -143,9 +143,14 @@ _imp_init_frozen(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("init_frozen", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
name = arg;
return_value = _imp_init_frozen_impl(module, name);
exit:
......@@ -170,9 +175,14 @@ _imp_get_frozen_object(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("get_frozen_object", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
name = arg;
return_value = _imp_get_frozen_object_impl(module, name);
exit:
......@@ -197,9 +207,14 @@ _imp_is_frozen_package(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_frozen_package", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
name = arg;
return_value = _imp_is_frozen_package_impl(module, name);
exit:
......@@ -224,9 +239,14 @@ _imp_is_builtin(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_builtin", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
name = arg;
return_value = _imp_is_builtin_impl(module, name);
exit:
......@@ -251,9 +271,14 @@ _imp_is_frozen(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("is_frozen", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
name = arg;
return_value = _imp_is_frozen_impl(module, name);
exit:
......@@ -396,4 +421,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=ad747b76e105fff2 input=a9049054013a1b77]*/
/*[clinic end generated code: output=d8be58c9541122f1 input=a9049054013a1b77]*/
......@@ -121,7 +121,11 @@ marshal_loads(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
Py_buffer bytes = {NULL, NULL};
if (!PyArg_Parse(arg, "y*:loads", &bytes)) {
if (PyObject_GetBuffer(arg, &bytes, PyBUF_SIMPLE) != 0) {
goto exit;
}
if (!PyBuffer_IsContiguous(&bytes, 'C')) {
_PyArg_BadArgument("loads", "contiguous buffer", arg);
goto exit;
}
return_value = marshal_loads_impl(module, &bytes);
......@@ -134,4 +138,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=cbb6128201bee7e0 input=a9049054013a1b77]*/
/*[clinic end generated code: output=8262e7e6c8cbc1ef input=a9049054013a1b77]*/
......@@ -612,6 +612,14 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Format an error message generated by convertsimple(). */
void
_PyArg_BadArgument(const char *fname, const char *expected, PyObject *arg)
{
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 *
converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
{
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment