bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index e78ca20..6569e02 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -19,7 +19,13 @@
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 @@
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 @@
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 @@
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 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=cb4bf8d50533953b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index 536f753..07c8866 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -296,7 +296,13 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=89538a941ae1267a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index a66fc99..bf40f7f 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -156,7 +156,13 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index 3ad3d67..f056416e 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -250,9 +250,14 @@
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 @@
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=a811badd76bfe92e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h
index 6e72da1..65cac66 100644
--- a/Modules/_io/clinic/winconsoleio.c.h
+++ b/Modules/_io/clinic/winconsoleio.c.h
@@ -156,7 +156,13 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/_sha3/clinic/sha3module.c.h b/Modules/_sha3/clinic/sha3module.c.h
index b2a896e..554442d 100644
--- a/Modules/_sha3/clinic/sha3module.c.h
+++ b/Modules/_sha3/clinic/sha3module.c.h
@@ -83,7 +83,7 @@
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 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=bf823532a7bffe68 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5b3e99b9a96471e8 input=a9049054013a1b77]*/
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 6767330..5954c13 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -96,7 +96,7 @@
[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 @@
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 @@
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 @@
/* 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 @@
}
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 @@
}
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);
diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h
index 74e45bd..1fef185 100644
--- a/Modules/cjkcodecs/clinic/multibytecodec.c.h
+++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h
@@ -150,9 +150,11 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/_bz2module.c.h b/Modules/clinic/_bz2module.c.h
index f538719..dce746d 100644
--- a/Modules/clinic/_bz2module.c.h
+++ b/Modules/clinic/_bz2module.c.h
@@ -25,7 +25,11 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=e47f4255d265b07d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8549cccdb82f57d9 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h
index 06f0572..360a134 100644
--- a/Modules/clinic/_codecsmodule.c.h
+++ b/Modules/clinic/_codecsmodule.c.h
@@ -33,7 +33,17 @@
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 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h
index 4f3f593..2e569c5 100644
--- a/Modules/clinic/_curses_panel.c.h
+++ b/Modules/clinic/_curses_panel.c.h
@@ -196,9 +196,11 @@
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 @@
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 @@
{
return _curses_panel_update_panels_impl(module);
}
-/*[clinic end generated code: output=66e49cb9726a638f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4b211b4015e29100 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h
index ac921d5..01c7097 100644
--- a/Modules/clinic/_cursesmodule.c.h
+++ b/Modules/clinic/_cursesmodule.c.h
@@ -273,7 +273,13 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/_elementtree.c.h b/Modules/clinic/_elementtree.c.h
index f7dc12e..e5107eb 100644
--- a/Modules/clinic/_elementtree.c.h
+++ b/Modules/clinic/_elementtree.c.h
@@ -19,9 +19,11 @@
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 @@
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 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=f1efdb511a5b027b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=398640585689c5ed input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_lzmamodule.c.h b/Modules/clinic/_lzmamodule.c.h
index 3e938c3..46d2988 100644
--- a/Modules/clinic/_lzmamodule.c.h
+++ b/Modules/clinic/_lzmamodule.c.h
@@ -25,7 +25,11 @@
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 @@
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 @@
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 @@
return return_value;
}
-/*[clinic end generated code: output=2acfd7c4b68530a6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=df061bfc2067a90a input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h
index fbc5ba4..e8a3665 100644
--- a/Modules/clinic/_sre.c.h
+++ b/Modules/clinic/_sre.c.h
@@ -47,7 +47,13 @@
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 @@
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 @@
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 @@
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 @@
{
return _sre_SRE_Scanner_search_impl(self);
}
-/*[clinic end generated code: output=5edeca5ec36b5f34 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h
index 82dc197..e149077 100644
--- a/Modules/clinic/_ssl.c.h
+++ b/Modules/clinic/_ssl.c.h
@@ -36,7 +36,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/_struct.c.h b/Modules/clinic/_struct.c.h
index b1fa067..3a186e4 100644
--- a/Modules/clinic/_struct.c.h
+++ b/Modules/clinic/_struct.c.h
@@ -57,7 +57,11 @@
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 @@
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 @@
return return_value;
}
-/*[clinic end generated code: output=a73b0453174e4b51 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=01516bea2641fe01 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/_tkinter.c.h b/Modules/clinic/_tkinter.c.h
index a09bc2d..1eedd2b 100644
--- a/Modules/clinic/_tkinter.c.h
+++ b/Modules/clinic/_tkinter.c.h
@@ -19,7 +19,17 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/_winapi.c.h b/Modules/clinic/_winapi.c.h
index 79d85ff..f1158a0 100644
--- a/Modules/clinic/_winapi.c.h
+++ b/Modules/clinic/_winapi.c.h
@@ -19,7 +19,8 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=145d0d362167c1b1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5063c84b2d125488 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/arraymodule.c.h b/Modules/clinic/arraymodule.c.h
index 0d10087..eb081ad 100644
--- a/Modules/clinic/arraymodule.c.h
+++ b/Modules/clinic/arraymodule.c.h
@@ -278,8 +278,22 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h
index 07ab24c..91f261c 100644
--- a/Modules/clinic/binascii.c.h
+++ b/Modules/clinic/binascii.c.h
@@ -20,7 +20,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return return_value;
}
-/*[clinic end generated code: output=3f45e15ce8b563b7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8ff0cb5717b15d1b input=a9049054013a1b77]*/
diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h
index 021c87d..30378c7 100644
--- a/Modules/clinic/cmathmodule.c.h
+++ b/Modules/clinic/cmathmodule.c.h
@@ -21,7 +21,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=17f6f65a229b1ef9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=50a105aa2bc5308f input=a9049054013a1b77]*/
diff --git a/Modules/clinic/gcmodule.c.h b/Modules/clinic/gcmodule.c.h
index 1c4be66..4fd2ea0 100644
--- a/Modules/clinic/gcmodule.c.h
+++ b/Modules/clinic/gcmodule.c.h
@@ -136,7 +136,13 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=ba67a1ab58780485 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5aa5fdc259503d5f input=a9049054013a1b77]*/
diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h
index c8d8029..e436f59 100644
--- a/Modules/clinic/mathmodule.c.h
+++ b/Modules/clinic/mathmodule.c.h
@@ -108,7 +108,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=8b1709a71e5fb855 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=da4b9940a5cb0188 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index eabfcf7..e310d99 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -185,7 +185,13 @@
PyObject *return_value = NULL;
int fd;
- if (!PyArg_Parse(arg, "i:ttyname", &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 = os_ttyname_impl(module, fd);
@@ -941,7 +947,7 @@
PyObject *return_value = NULL;
path_t path = PATH_T_INITIALIZE("_getfullpathname", "path", 0, 0);
- if (!PyArg_Parse(arg, "O&:_getfullpathname", path_converter, &path)) {
+ if (!path_converter(arg, &path)) {
goto exit;
}
return_value = os__getfullpathname_impl(module, &path);
@@ -975,7 +981,7 @@
PyObject *return_value = NULL;
path_t path = PATH_T_INITIALIZE("_getfinalpathname", "path", 0, 0);
- if (!PyArg_Parse(arg, "O&:_getfinalpathname", path_converter, &path)) {
+ if (!path_converter(arg, &path)) {
goto exit;
}
return_value = os__getfinalpathname_impl(module, &path);
@@ -1101,7 +1107,13 @@
PyObject *return_value = NULL;
int increment;
- if (!PyArg_Parse(arg, "i:nice", &increment)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ increment = _PyLong_AsInt(arg);
+ if (increment == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_nice_impl(module, increment);
@@ -1411,7 +1423,13 @@
PyObject *return_value = NULL;
int mask;
- if (!PyArg_Parse(arg, "i:umask", &mask)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ mask = _PyLong_AsInt(arg);
+ if (mask == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_umask_impl(module, mask);
@@ -2725,7 +2743,13 @@
PyObject *return_value = NULL;
int op;
- if (!PyArg_Parse(arg, "i:plock", &op)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ op = _PyLong_AsInt(arg);
+ if (op == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_plock_impl(module, op);
@@ -2756,7 +2780,7 @@
PyObject *return_value = NULL;
uid_t uid;
- if (!PyArg_Parse(arg, "O&:setuid", _Py_Uid_Converter, &uid)) {
+ if (!_Py_Uid_Converter(arg, &uid)) {
goto exit;
}
return_value = os_setuid_impl(module, uid);
@@ -2787,7 +2811,7 @@
PyObject *return_value = NULL;
uid_t euid;
- if (!PyArg_Parse(arg, "O&:seteuid", _Py_Uid_Converter, &euid)) {
+ if (!_Py_Uid_Converter(arg, &euid)) {
goto exit;
}
return_value = os_seteuid_impl(module, euid);
@@ -2818,7 +2842,7 @@
PyObject *return_value = NULL;
gid_t egid;
- if (!PyArg_Parse(arg, "O&:setegid", _Py_Gid_Converter, &egid)) {
+ if (!_Py_Gid_Converter(arg, &egid)) {
goto exit;
}
return_value = os_setegid_impl(module, egid);
@@ -2915,7 +2939,7 @@
PyObject *return_value = NULL;
gid_t gid;
- if (!PyArg_Parse(arg, "O&:setgid", _Py_Gid_Converter, &gid)) {
+ if (!_Py_Gid_Converter(arg, &gid)) {
goto exit;
}
return_value = os_setgid_impl(module, gid);
@@ -3389,7 +3413,13 @@
PyObject *return_value = NULL;
int fd;
- if (!PyArg_Parse(arg, "i:tcgetpgrp", &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 = os_tcgetpgrp_impl(module, fd);
@@ -3557,7 +3587,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:dup", &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 = os_dup_impl(module, fd);
@@ -3981,7 +4017,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:isatty", &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 = os_isatty_impl(module, fd);
@@ -4045,7 +4087,13 @@
PyObject *return_value = NULL;
int flags;
- if (!PyArg_Parse(arg, "i:pipe2", &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 = os_pipe2_impl(module, flags);
@@ -4318,7 +4366,7 @@
dev_t device;
unsigned int _return_value;
- if (!PyArg_Parse(arg, "O&:major", _Py_Dev_Converter, &device)) {
+ if (!_Py_Dev_Converter(arg, &device)) {
goto exit;
}
_return_value = os_major_impl(module, device);
@@ -4354,7 +4402,7 @@
dev_t device;
unsigned int _return_value;
- if (!PyArg_Parse(arg, "O&:minor", _Py_Dev_Converter, &device)) {
+ if (!_Py_Dev_Converter(arg, &device)) {
goto exit;
}
_return_value = os_minor_impl(module, device);
@@ -4654,7 +4702,7 @@
PyObject *return_value = NULL;
PyObject *name = NULL;
- if (!PyArg_Parse(arg, "O&:unsetenv", PyUnicode_FSConverter, &name)) {
+ if (!PyUnicode_FSConverter(arg, &name)) {
goto exit;
}
return_value = os_unsetenv_impl(module, name);
@@ -4686,7 +4734,13 @@
PyObject *return_value = NULL;
int code;
- if (!PyArg_Parse(arg, "i:strerror", &code)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ code = _PyLong_AsInt(arg);
+ if (code == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = os_strerror_impl(module, code);
@@ -4716,7 +4770,13 @@
int status;
int _return_value;
- if (!PyArg_Parse(arg, "i:WCOREDUMP", &status)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ status = _PyLong_AsInt(arg);
+ if (status == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = os_WCOREDUMP_impl(module, status);
@@ -5029,7 +5089,13 @@
PyObject *return_value = NULL;
int fd;
- if (!PyArg_Parse(arg, "i:fstatvfs", &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 = os_fstatvfs_impl(module, fd);
@@ -5225,7 +5291,7 @@
PyObject *return_value = NULL;
int name;
- if (!PyArg_Parse(arg, "O&:confstr", conv_confstr_confname, &name)) {
+ if (!conv_confstr_confname(arg, &name)) {
goto exit;
}
return_value = os_confstr_impl(module, name);
@@ -5257,7 +5323,7 @@
int name;
long _return_value;
- if (!PyArg_Parse(arg, "O&:sysconf", conv_sysconf_confname, &name)) {
+ if (!conv_sysconf_confname(arg, &name)) {
goto exit;
}
_return_value = os_sysconf_impl(module, name);
@@ -5730,9 +5796,23 @@
PyObject *return_value = NULL;
Py_ssize_t size;
- if (!PyArg_Parse(arg, "n:urandom", &size)) {
+ 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;
+ }
+ size = ival;
+ }
return_value = os_urandom_impl(module, size);
exit:
@@ -5780,7 +5860,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:get_inheritable", &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 = os_get_inheritable_impl(module, fd);
@@ -5915,7 +6001,13 @@
int fd;
int _return_value;
- if (!PyArg_Parse(arg, "i:get_blocking", &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 = os_get_blocking_impl(module, fd);
@@ -6753,4 +6845,4 @@
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
-/*[clinic end generated code: output=87a3ebadb91bc46b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b02036b2a269b1db input=a9049054013a1b77]*/
diff --git a/Modules/clinic/pwdmodule.c.h b/Modules/clinic/pwdmodule.c.h
index 979dfdb..9270be0 100644
--- a/Modules/clinic/pwdmodule.c.h
+++ b/Modules/clinic/pwdmodule.c.h
@@ -33,9 +33,14 @@
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 @@
#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]*/
diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h
index 5e6db44..1545485 100644
--- a/Modules/clinic/pyexpat.c.h
+++ b/Modules/clinic/pyexpat.c.h
@@ -61,7 +61,17 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/resource.c.h b/Modules/clinic/resource.c.h
index cd9fae1..0a66f8f 100644
--- a/Modules/clinic/resource.c.h
+++ b/Modules/clinic/resource.c.h
@@ -19,7 +19,13 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h
index 0a53ae2..bb69d95 100644
--- a/Modules/clinic/selectmodule.c.h
+++ b/Modules/clinic/selectmodule.c.h
@@ -153,7 +153,7 @@
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 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/signalmodule.c.h b/Modules/clinic/signalmodule.c.h
index 912f989..6745f45 100644
--- a/Modules/clinic/signalmodule.c.h
+++ b/Modules/clinic/signalmodule.c.h
@@ -23,7 +23,13 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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]*/
diff --git a/Modules/clinic/spwdmodule.c.h b/Modules/clinic/spwdmodule.c.h
index b2479ff..a0a3e2e 100644
--- a/Modules/clinic/spwdmodule.c.h
+++ b/Modules/clinic/spwdmodule.c.h
@@ -24,9 +24,14 @@
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 @@
#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]*/
diff --git a/Modules/clinic/unicodedata.c.h b/Modules/clinic/unicodedata.c.h
index 4799fb4..9e8d261 100644
--- a/Modules/clinic/unicodedata.c.h
+++ b/Modules/clinic/unicodedata.c.h
@@ -121,9 +121,18 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=67f474927be668bf input=a9049054013a1b77]*/
+/*[clinic end generated code: output=709241b99d010896 input=a9049054013a1b77]*/
diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h
index c5eeab7..87ad1ea 100644
--- a/Modules/clinic/zlibmodule.c.h
+++ b/Modules/clinic/zlibmodule.c.h
@@ -215,7 +215,11 @@
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 @@
#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]*/