summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-25 11:23:47 (GMT)
committerGitHub <noreply@github.com>2018-12-25 11:23:47 (GMT)
commit32d96a2b5bc3136d45a66adbdb45fac351b520ce (patch)
treeacf51c9945f764ab103597c9cba376f154aa600d /Modules
parent65ce60aef150776f884715b4315a10a0d6ae769e (diff)
downloadcpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.zip
cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.gz
cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.bz2
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/clinic/bufferedio.c.h40
-rw-r--r--Modules/_io/clinic/bytesio.c.h10
-rw-r--r--Modules/_io/clinic/fileio.c.h16
-rw-r--r--Modules/_io/clinic/textio.c.h9
-rw-r--r--Modules/_io/clinic/winconsoleio.c.h16
-rw-r--r--Modules/_sha3/clinic/sha3module.c.h6
-rw-r--r--Modules/_struct.c12
-rw-r--r--Modules/cjkcodecs/clinic/multibytecodec.c.h10
-rw-r--r--Modules/clinic/_bz2module.c.h8
-rw-r--r--Modules/clinic/_codecsmodule.c.h45
-rw-r--r--Modules/clinic/_curses_panel.c.h10
-rw-r--r--Modules/clinic/_cursesmodule.c.h254
-rw-r--r--Modules/clinic/_elementtree.c.h14
-rw-r--r--Modules/clinic/_lzmamodule.c.h18
-rw-r--r--Modules/clinic/_sre.c.h34
-rw-r--r--Modules/clinic/_ssl.c.h66
-rw-r--r--Modules/clinic/_struct.c.h10
-rw-r--r--Modules/clinic/_tkinter.c.h118
-rw-r--r--Modules/clinic/_winapi.c.h5
-rw-r--r--Modules/clinic/arraymodule.c.h26
-rw-r--r--Modules/clinic/binascii.c.h42
-rw-r--r--Modules/clinic/cmathmodule.c.h62
-rw-r--r--Modules/clinic/gcmodule.c.h10
-rw-r--r--Modules/clinic/mathmodule.c.h23
-rw-r--r--Modules/clinic/posixmodule.c.h144
-rw-r--r--Modules/clinic/pwdmodule.c.h9
-rw-r--r--Modules/clinic/pyexpat.c.h30
-rw-r--r--Modules/clinic/resource.c.h18
-rw-r--r--Modules/clinic/selectmodule.c.h22
-rw-r--r--Modules/clinic/signalmodule.c.h38
-rw-r--r--Modules/clinic/spwdmodule.c.h9
-rw-r--r--Modules/clinic/unicodedata.c.h68
-rw-r--r--Modules/clinic/zlibmodule.c.h8
33 files changed, 1004 insertions, 206 deletions
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ 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);
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _curses_window_attroff(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
long attr;
- if (!PyArg_Parse(arg, "l:attroff", &attr)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = PyLong_AsLong(arg);
+ if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_attroff_impl(self, attr);
@@ -300,7 +306,13 @@ _curses_window_attron(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
long attr;
- if (!PyArg_Parse(arg, "l:attron", &attr)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = PyLong_AsLong(arg);
+ if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_attron_impl(self, attr);
@@ -327,7 +339,13 @@ _curses_window_attrset(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
long attr;
- if (!PyArg_Parse(arg, "l:attrset", &attr)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = PyLong_AsLong(arg);
+ if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_attrset_impl(self, attr);
@@ -1198,7 +1216,13 @@ _curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg)
PyObject *return_value = NULL;
int line;
- if (!PyArg_Parse(arg, "i:is_linetouched", &line)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ line = _PyLong_AsInt(arg);
+ if (line == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_window_is_linetouched_impl(self, line);
@@ -1888,9 +1912,30 @@ _curses_color_content(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
short color_number;
- if (!PyArg_Parse(arg, "h:color_content", &color_number)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(arg);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ color_number = (short) ival;
+ }
+ }
return_value = _curses_color_content_impl(module, color_number);
exit:
@@ -1921,9 +1966,30 @@ _curses_color_pair(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
short color_number;
- if (!PyArg_Parse(arg, "h:color_pair", &color_number)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(arg);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ color_number = (short) ival;
+ }
+ }
return_value = _curses_color_pair_impl(module, color_number);
exit:
@@ -1956,7 +2022,13 @@ _curses_curs_set(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int visibility;
- if (!PyArg_Parse(arg, "i:curs_set", &visibility)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ visibility = _PyLong_AsInt(arg);
+ if (visibility == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_curs_set_impl(module, visibility);
@@ -2030,7 +2102,13 @@ _curses_delay_output(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int ms;
- if (!PyArg_Parse(arg, "i:delay_output", &ms)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ ms = _PyLong_AsInt(arg);
+ if (ms == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_delay_output_impl(module, ms);
@@ -2290,9 +2368,30 @@ _curses_halfdelay(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
unsigned char tenths;
- if (!PyArg_Parse(arg, "b:halfdelay", &tenths)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(arg);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned byte integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > UCHAR_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned byte integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ tenths = (unsigned char) ival;
+ }
+ }
return_value = _curses_halfdelay_impl(module, tenths);
exit:
@@ -2376,7 +2475,13 @@ _curses_has_key(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int key;
- if (!PyArg_Parse(arg, "i:has_key", &key)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ key = _PyLong_AsInt(arg);
+ if (key == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_has_key_impl(module, key);
@@ -2548,7 +2653,13 @@ _curses_intrflush(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int flag;
- if (!PyArg_Parse(arg, "i:intrflush", &flag)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(arg);
+ if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_intrflush_impl(module, flag);
@@ -2634,7 +2745,13 @@ _curses_keyname(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int key;
- if (!PyArg_Parse(arg, "i:keyname", &key)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ key = _PyLong_AsInt(arg);
+ if (key == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_keyname_impl(module, key);
@@ -2703,7 +2820,13 @@ _curses_meta(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int yes;
- if (!PyArg_Parse(arg, "i:meta", &yes)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ yes = _PyLong_AsInt(arg);
+ if (yes == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_meta_impl(module, yes);
@@ -2739,7 +2862,13 @@ _curses_mouseinterval(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int interval;
- if (!PyArg_Parse(arg, "i:mouseinterval", &interval)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ interval = _PyLong_AsInt(arg);
+ if (interval == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_mouseinterval_impl(module, interval);
@@ -2775,9 +2904,11 @@ _curses_mousemask(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
unsigned long newmask;
- if (!PyArg_Parse(arg, "k:mousemask", &newmask)) {
+ if (!PyLong_Check(arg)) {
+ _PyArg_BadArgument("mousemask", "int", arg);
goto exit;
}
+ newmask = PyLong_AsUnsignedLongMask(arg);
return_value = _curses_mousemask_impl(module, newmask);
exit:
@@ -2807,7 +2938,13 @@ _curses_napms(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int ms;
- if (!PyArg_Parse(arg, "i:napms", &ms)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ ms = _PyLong_AsInt(arg);
+ if (ms == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_napms_impl(module, ms);
@@ -3062,9 +3199,30 @@ _curses_pair_content(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
short pair_number;
- if (!PyArg_Parse(arg, "h:pair_content", &pair_number)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ long ival = PyLong_AsLong(arg);
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ else if (ival < SHRT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is less than minimum");
+ goto exit;
+ }
+ else if (ival > SHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "signed short integer is greater than maximum");
+ goto exit;
+ }
+ else {
+ pair_number = (short) ival;
+ }
+ }
return_value = _curses_pair_content_impl(module, pair_number);
exit:
@@ -3091,7 +3249,13 @@ _curses_pair_number(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int attr;
- if (!PyArg_Parse(arg, "i:pair_number", &attr)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ attr = _PyLong_AsInt(arg);
+ if (attr == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_pair_number_impl(module, attr);
@@ -3511,7 +3675,17 @@ _curses_tigetflag(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *capname;
- if (!PyArg_Parse(arg, "s:tigetflag", &capname)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("tigetflag", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t capname_length;
+ capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
+ if (capname == NULL) {
+ goto exit;
+ }
+ if (strlen(capname) != (size_t)capname_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _curses_tigetflag_impl(module, capname);
@@ -3544,7 +3718,17 @@ _curses_tigetnum(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *capname;
- if (!PyArg_Parse(arg, "s:tigetnum", &capname)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("tigetnum", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t capname_length;
+ capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
+ if (capname == NULL) {
+ goto exit;
+ }
+ if (strlen(capname) != (size_t)capname_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _curses_tigetnum_impl(module, capname);
@@ -3577,7 +3761,17 @@ _curses_tigetstr(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
const char *capname;
- if (!PyArg_Parse(arg, "s:tigetstr", &capname)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("tigetstr", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t capname_length;
+ capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
+ if (capname == NULL) {
+ goto exit;
+ }
+ if (strlen(capname) != (size_t)capname_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _curses_tigetstr_impl(module, capname);
@@ -3653,7 +3847,13 @@ _curses_typeahead(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int fd;
- if (!PyArg_Parse(arg, "i:typeahead", &fd)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ fd = _PyLong_AsInt(arg);
+ if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_typeahead_impl(module, fd);
@@ -3727,7 +3927,13 @@ _curses_use_env(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
int flag;
- if (!PyArg_Parse(arg, "i:use_env", &flag)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ flag = _PyLong_AsInt(arg);
+ if (flag == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_use_env_impl(module, flag);
@@ -3838,4 +4044,4 @@ _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=177ad1d0b5586aaa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a2bbced3c5d29d64 input=a9049054013a1b77]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ 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]*/
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 @@ _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]*/
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 @@ _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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ os_ttyname(PyObject *module, PyObject *arg)
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 @@ os__getfullpathname(PyObject *module, PyObject *arg)
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 @@ os__getfinalpathname(PyObject *module, PyObject *arg)
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 @@ os_nice(PyObject *module, PyObject *arg)
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 @@ os_umask(PyObject *module, PyObject *arg)
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 @@ os_plock(PyObject *module, PyObject *arg)
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 @@ os_setuid(PyObject *module, PyObject *arg)
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 @@ os_seteuid(PyObject *module, PyObject *arg)
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 @@ os_setegid(PyObject *module, PyObject *arg)
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 @@ os_setgid(PyObject *module, PyObject *arg)
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 @@ os_tcgetpgrp(PyObject *module, PyObject *arg)
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 @@ os_dup(PyObject *module, PyObject *arg)
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 @@ os_isatty(PyObject *module, PyObject *arg)
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 @@ os_pipe2(PyObject *module, PyObject *arg)
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 @@ os_major(PyObject *module, PyObject *arg)
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 @@ os_minor(PyObject *module, PyObject *arg)
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 @@ os_unsetenv(PyObject *module, PyObject *arg)
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 @@ os_strerror(PyObject *module, PyObject *arg)
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 @@ os_WCOREDUMP(PyObject *module, PyObject *arg)
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 @@ os_fstatvfs(PyObject *module, PyObject *arg)
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 @@ os_confstr(PyObject *module, PyObject *arg)
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 @@ os_sysconf(PyObject *module, PyObject *arg)
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 @@ os_urandom(PyObject *module, PyObject *arg)
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 @@ os_get_inheritable(PyObject *module, PyObject *arg)
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 @@ os_get_blocking(PyObject *module, PyObject *arg)
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 @@ exit:
#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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/
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 @@ 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]*/