#define _PyArg_NoPositional(funcname, args) \
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
+PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, PyObject *);
+
#endif
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
PyObject *return_value = NULL;
PyBytesObject *a;
- if (!PyArg_Parse(arg, "S:test_PyBytesObject_converter", &a)) {
+ if (!PyBytes_Check(arg)) {
+ _PyArg_BadArgument("test_PyBytesObject_converter", "bytes", arg);
goto exit;
}
+ a = (PyBytesObject *)arg;
return_value = test_PyBytesObject_converter_impl(module, a);
exit:
static PyObject *
test_PyBytesObject_converter_impl(PyObject *module, PyBytesObject *a)
-/*[clinic end generated code: output=8dbf43c604ced031 input=12b10c7cb5750400]*/
+/*[clinic end generated code: output=fd69d6df4d26c853 input=12b10c7cb5750400]*/
/*[clinic input]
test_PyByteArrayObject_converter
PyObject *return_value = NULL;
PyByteArrayObject *a;
- if (!PyArg_Parse(arg, "Y:test_PyByteArrayObject_converter", &a)) {
+ if (!PyByteArray_Check(arg)) {
+ _PyArg_BadArgument("test_PyByteArrayObject_converter", "bytearray", arg);
goto exit;
}
+ a = (PyByteArrayObject *)arg;
return_value = test_PyByteArrayObject_converter_impl(module, a);
exit:
static PyObject *
test_PyByteArrayObject_converter_impl(PyObject *module, PyByteArrayObject *a)
-/*[clinic end generated code: output=ade99fc6705e7d6e input=5a657da535d194ae]*/
+/*[clinic end generated code: output=d309c909182c4183 input=5a657da535d194ae]*/
/*[clinic input]
test_unicode_converter
PyObject *return_value = NULL;
PyObject *a;
- if (!PyArg_Parse(arg, "U:test_unicode_converter", &a)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("test_unicode_converter", "str", arg);
goto exit;
}
+ if (PyUnicode_READY(arg) == -1) {
+ goto exit;
+ }
+ a = arg;
return_value = test_unicode_converter_impl(module, a);
exit:
static PyObject *
test_unicode_converter_impl(PyObject *module, PyObject *a)
-/*[clinic end generated code: output=504a2c8d00370adf input=aa33612df92aa9c5]*/
+/*[clinic end generated code: output=ca603454e1f8f764 input=aa33612df92aa9c5]*/
/*[clinic input]
test_bool_converter
PyObject *return_value = NULL;
Py_complex a;
- if (!PyArg_Parse(arg, "D:test_Py_complex_converter", &a)) {
+ a = PyComplex_AsCComplex(arg);
+ if (PyErr_Occurred()) {
goto exit;
}
return_value = test_Py_complex_converter_impl(module, a);
static PyObject *
test_Py_complex_converter_impl(PyObject *module, Py_complex a)
-/*[clinic end generated code: output=27efb4ff772d6170 input=070f216a515beb79]*/
+/*[clinic end generated code: output=c2ecbec2144ca540 input=070f216a515beb79]*/
/*[clinic input]
test_str_converter
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);
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);
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);
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);
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=cb4bf8d50533953b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=89538a941ae1267a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/
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);
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);
#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]*/
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:
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=a811badd76bfe92e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/
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);
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);
#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]*/
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);
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=bf823532a7bffe68 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5b3e99b9a96471e8 input=a9049054013a1b77]*/
[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"
static PyObject *cache = NULL;
static int
-cache_struct_converter(PyObject *fmt, PyObject **ptr)
+cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
{
PyObject * s_object;
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;
}
/* 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;
}
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);
}
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);
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:
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:
#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]*/
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=e47f4255d265b07d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8549cccdb82f57d9 input=a9049054013a1b77]*/
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);
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);
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:
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);
#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]*/
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:
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:
{
return _curses_panel_update_panels_impl(module);
}
-/*[clinic end generated code: output=66e49cb9726a638f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4b211b4015e29100 input=a9049054013a1b77]*/
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);
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);
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);
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);
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:
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:
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);
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);
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:
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);
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);
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);
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);
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);
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:
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);
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:
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);
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);
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);
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);
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);
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);
#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]*/
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:
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:
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:
exit:
return return_value;
}
-/*[clinic end generated code: output=f1efdb511a5b027b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=398640585689c5ed input=a9049054013a1b77]*/
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);
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);
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);
return return_value;
}
-/*[clinic end generated code: output=2acfd7c4b68530a6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=df061bfc2067a90a input=a9049054013a1b77]*/
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);
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);
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);
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);
{
return _sre_SRE_Scanner_search_impl(self);
}
-/*[clinic end generated code: output=5edeca5ec36b5f34 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
#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]*/
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);
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);
return return_value;
}
-/*[clinic end generated code: output=a73b0453174e4b51 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=01516bea2641fe01 input=a9049054013a1b77]*/
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
#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]*/
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=145d0d362167c1b1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5063c84b2d125488 input=a9049054013a1b77]*/
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);
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);
#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]*/
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
return return_value;
}
-/*[clinic end generated code: output=3f45e15ce8b563b7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8ff0cb5717b15d1b input=a9049054013a1b77]*/
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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);
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);
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);
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);
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=17f6f65a229b1ef9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=50a105aa2bc5308f input=a9049054013a1b77]*/
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=ba67a1ab58780485 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5aa5fdc259503d5f input=a9049054013a1b77]*/
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);
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);
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);
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);
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);
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);
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);
exit:
return return_value;
}
-/*[clinic end generated code: output=8b1709a71e5fb855 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=da4b9940a5cb0188 input=a9049054013a1b77]*/
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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:
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);
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);
#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]*/
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:
#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]*/
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);
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);
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);
#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]*/
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);
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);
#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]*/
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);
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);
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);
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);
#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]*/
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);
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);
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);
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);
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);
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);
#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]*/
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:
#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]*/
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:
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:
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;
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;
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:
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:
exit:
return return_value;
}
-/*[clinic end generated code: output=67f474927be668bf input=a9049054013a1b77]*/
+/*[clinic end generated code: output=709241b99d010896 input=a9049054013a1b77]*/
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);
#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]*/
PyObject *return_value = NULL;
int item;
- if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item)) {
+ if (!_getbytevalue(arg, &item)) {
goto exit;
}
return_value = bytearray_append_impl(self, item);
PyObject *return_value = NULL;
int value;
- if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value)) {
+ if (!_getbytevalue(arg, &value)) {
goto exit;
}
return_value = bytearray_remove_impl(self, value);
PyObject *return_value = NULL;
PyObject *string;
- if (!PyArg_Parse(arg, "U:fromhex", &string)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("fromhex", "str", arg);
goto exit;
}
+ if (PyUnicode_READY(arg) == -1) {
+ goto exit;
+ }
+ string = arg;
return_value = bytearray_fromhex_impl(type, string);
exit:
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=b88bb192dddca6e1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cd3e13a1905a473c input=a9049054013a1b77]*/
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:partition", &sep)) {
+ if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&sep, 'C')) {
+ _PyArg_BadArgument("partition", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_partition_impl(self, &sep);
PyObject *return_value = NULL;
Py_buffer sep = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:rpartition", &sep)) {
+ if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&sep, 'C')) {
+ _PyArg_BadArgument("rpartition", "contiguous buffer", arg);
goto exit;
}
return_value = bytes_rpartition_impl(self, &sep);
PyObject *return_value = NULL;
PyObject *string;
- if (!PyArg_Parse(arg, "U:fromhex", &string)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("fromhex", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ string = arg;
return_value = bytes_fromhex_impl(type, string);
exit:
return return_value;
}
-/*[clinic end generated code: output=07b33ac65362301b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=dc9aa04f0007ab11 input=a9049054013a1b77]*/
PyObject *return_value = NULL;
const char *typestr;
- if (!PyArg_Parse(arg, "s:__getformat__", &typestr)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("__getformat__", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t typestr_length;
+ typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length);
+ if (typestr == NULL) {
+ goto exit;
+ }
+ if (strlen(typestr) != (size_t)typestr_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = float___getformat___impl(type, typestr);
PyObject *return_value = NULL;
PyObject *format_spec;
- if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("__format__", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ format_spec = arg;
return_value = float___format___impl(self, format_spec);
exit:
return return_value;
}
-/*[clinic end generated code: output=091dd499f5386a6c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/
PyObject *return_value = NULL;
PyObject *format_spec;
- if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("__format__", "str", arg);
goto exit;
}
+ if (PyUnicode_READY(arg) == -1) {
+ goto exit;
+ }
+ format_spec = arg;
return_value = int___format___impl(self, format_spec);
exit:
exit:
return return_value;
}
-/*[clinic end generated code: output=403ccd096555fd1e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7436b5f4decdcf9d input=a9049054013a1b77]*/
PyObject *return_value = NULL;
int protocol;
- if (!PyArg_Parse(arg, "i:__reduce_ex__", &protocol)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ protocol = _PyLong_AsInt(arg);
+ if (protocol == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = object___reduce_ex___impl(self, protocol);
PyObject *return_value = NULL;
PyObject *format_spec;
- if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("__format__", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ format_spec = arg;
return_value = object___format___impl(self, format_spec);
exit:
{
return object___dir___impl(self);
}
-/*[clinic end generated code: output=8c4c856859564eaa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=09f3453839e60136 input=a9049054013a1b77]*/
PyObject *return_value = NULL;
Py_ssize_t width;
- if (!PyArg_Parse(arg, "n:zfill", &width)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(arg);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ width = ival;
+ }
return_value = unicode_zfill_impl(self, width);
exit:
PyObject *return_value = NULL;
PyObject *format_spec;
- if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("__format__", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ format_spec = arg;
return_value = unicode___format___impl(self, format_spec);
exit:
{
return unicode_sizeof_impl(self);
}
-/*[clinic end generated code: output=d323802b67bfc6d8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ff6acd5abd1998eb input=a9049054013a1b77]*/
PyObject *return_value = NULL;
Py_ssize_t width;
- if (!PyArg_Parse(arg, "n:zfill", &width)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(arg);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ width = ival;
+ }
return_value = stringlib_zfill_impl(self, width);
exit:
return return_value;
}
-/*[clinic end generated code: output=d09ba158d470566e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=bf2ef501639e1190 input=a9049054013a1b77]*/
int fd;
void *_return_value;
- if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ fd = _PyLong_AsInt(arg);
+ if (fd == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = msvcrt_get_osfhandle_impl(module, fd);
PyObject *return_value = NULL;
char char_value;
- if (!PyArg_Parse(arg, "c:putch", &char_value)) {
+ if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
+ char_value = PyBytes_AS_STRING(arg)[0];
+ }
+ else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
+ char_value = PyByteArray_AS_STRING(arg)[0];
+ }
+ else {
+ _PyArg_BadArgument("putch", "a byte string of length 1", arg);
goto exit;
}
return_value = msvcrt_putch_impl(module, char_value);
PyObject *return_value = NULL;
int unicode_char;
- if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("putwch", "a unicode character", arg);
goto exit;
}
+ if (PyUnicode_READY(arg)) {
+ goto exit;
+ }
+ if (PyUnicode_GET_LENGTH(arg) != 1) {
+ _PyArg_BadArgument("putwch", "a unicode character", arg);
+ goto exit;
+ }
+ unicode_char = PyUnicode_READ_CHAR(arg, 0);
return_value = msvcrt_putwch_impl(module, unicode_char);
exit:
PyObject *return_value = NULL;
char char_value;
- if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
+ if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
+ char_value = PyBytes_AS_STRING(arg)[0];
+ }
+ else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
+ char_value = PyByteArray_AS_STRING(arg)[0];
+ }
+ else {
+ _PyArg_BadArgument("ungetch", "a byte string of length 1", arg);
goto exit;
}
return_value = msvcrt_ungetch_impl(module, char_value);
PyObject *return_value = NULL;
int unicode_char;
- if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("ungetwch", "a unicode character", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg)) {
+ goto exit;
+ }
+ if (PyUnicode_GET_LENGTH(arg) != 1) {
+ _PyArg_BadArgument("ungetwch", "a unicode character", arg);
goto exit;
}
+ unicode_char = PyUnicode_READ_CHAR(arg, 0);
return_value = msvcrt_ungetwch_impl(module, unicode_char);
exit:
int mode;
long _return_value;
- if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ mode = _PyLong_AsInt(arg);
+ if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
_return_value = msvcrt_set_error_mode_impl(module, mode);
PyObject *return_value = NULL;
unsigned int mode;
- if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ mode = (unsigned int)PyLong_AsUnsignedLongMask(arg);
+ if (mode == (unsigned int)-1 && PyErr_Occurred()) {
goto exit;
}
return_value = msvcrt_SetErrorMode_impl(module, mode);
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
#define MSVCRT_SET_ERROR_MODE_METHODDEF
#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
-/*[clinic end generated code: output=632089ff9236ac77 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2530b4ff248563b4 input=a9049054013a1b77]*/
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) {
+ if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_FlushKey_impl(module, key);
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) {
+ if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_QueryInfoKey_impl(module, key);
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) {
+ if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_DisableReflectionKey_impl(module, key);
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) {
+ if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_EnableReflectionKey_impl(module, key);
PyObject *return_value = NULL;
HKEY key;
- if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) {
+ if (!clinic_HKEY_converter(arg, &key)) {
goto exit;
}
return_value = winreg_QueryReflectionKey_impl(module, key);
exit:
return return_value;
}
-/*[clinic end generated code: output=ff2cc1951ab1a56c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=82bd56c524c6c3dd input=a9049054013a1b77]*/
PyObject *return_value = NULL;
int i;
- if (!PyArg_Parse(arg, "i:chr", &i)) {
+ if (PyFloat_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ i = _PyLong_AsInt(arg);
+ if (i == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = builtin_chr_impl(module, i);
exit:
return return_value;
}
-/*[clinic end generated code: output=fa8d97ac8695363b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("init_frozen", "str", arg);
goto exit;
}
+ if (PyUnicode_READY(arg) == -1) {
+ goto exit;
+ }
+ name = arg;
return_value = _imp_init_frozen_impl(module, name);
exit:
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("get_frozen_object", "str", arg);
goto exit;
}
+ if (PyUnicode_READY(arg) == -1) {
+ goto exit;
+ }
+ name = arg;
return_value = _imp_get_frozen_object_impl(module, name);
exit:
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("is_frozen_package", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ name = arg;
return_value = _imp_is_frozen_package_impl(module, name);
exit:
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("is_builtin", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ name = arg;
return_value = _imp_is_builtin_impl(module, name);
exit:
PyObject *return_value = NULL;
PyObject *name;
- if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("is_frozen", "str", arg);
+ goto exit;
+ }
+ if (PyUnicode_READY(arg) == -1) {
goto exit;
}
+ name = arg;
return_value = _imp_is_frozen_impl(module, name);
exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=ad747b76e105fff2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d8be58c9541122f1 input=a9049054013a1b77]*/
PyObject *return_value = NULL;
Py_buffer bytes = {NULL, NULL};
- if (!PyArg_Parse(arg, "y*:loads", &bytes)) {
+ if (PyObject_GetBuffer(arg, &bytes, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&bytes, 'C')) {
+ _PyArg_BadArgument("loads", "contiguous buffer", arg);
goto exit;
}
return_value = marshal_loads_impl(module, &bytes);
return return_value;
}
-/*[clinic end generated code: output=cbb6128201bee7e0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=8262e7e6c8cbc1ef input=a9049054013a1b77]*/
/* Format an error message generated by convertsimple(). */
+void
+_PyArg_BadArgument(const char *fname, const char *expected, PyObject *arg)
+{
+ PyErr_Format(PyExc_TypeError, "%.200s() argument must be %.50s, not %.50s",
+ fname, expected,
+ arg == Py_None ? "None" : arg->ob_type->tp_name);
+}
+
static const char *
converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
{
{c_basename}({self_type}{self_name}, PyObject *%s)
""" % argname)
- parser_definition = parser_body(parser_prototype, normalize_snippet("""
- if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{
- goto exit;
- }}
- """ % argname, indent=4))
+ parsearg = converters[0].parse_arg(argname)
+ assert parsearg is not None
+ parser_definition = parser_body(parser_prototype,
+ normalize_snippet(parsearg, indent=4))
elif has_option_groups:
# positional parameters with option groups
# keep in sync with self_converter.__init__!
def __init__(self, name, py_name, function, default=unspecified, *, c_default=None, py_default=None, annotation=unspecified, **kwargs):
- self.name = name
+ self.name = ensure_legal_c_identifier(name)
self.py_name = py_name
if default is not unspecified:
def _render_self(self, parameter, data):
self.parameter = parameter
- original_name = self.name
- name = ensure_legal_c_identifier(original_name)
+ name = self.name
# impl_arguments
s = ("&" if self.impl_by_reference else "") + name
def _render_non_self(self, parameter, data):
self.parameter = parameter
- original_name = self.name
- name = ensure_legal_c_identifier(original_name)
+ name = self.name
# declarations
d = self.declaration()
"""Computes the name of the associated "length" variable."""
if not self.length:
return None
- return ensure_legal_c_identifier(self.name) + "_length"
+ return self.name + "_length"
# Why is this one broken out separately?
# For "positional-only" function parsing,
elif self.subclass_of:
list.append(self.subclass_of)
- legal_name = ensure_legal_c_identifier(self.name)
- s = ("&" if self.parse_by_reference else "") + legal_name
+ s = ("&" if self.parse_by_reference else "") + self.name
list.append(s)
if self.length:
prototype.append(" ")
if by_reference:
prototype.append('*')
- prototype.append(ensure_legal_c_identifier(self.name))
+ prototype.append(self.name)
return "".join(prototype)
def declaration(self):
"""
pass
+ def parse_arg(self, argname):
+ if self.format_unit == 'O&':
+ return """
+ if (!{converter}({argname}, &{paramname})) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name,
+ converter=self.converter)
+ if self.format_unit == 'O!':
+ cast = '(%s)' % self.type if self.type != 'PyObject *' else ''
+ if self.subclass_of in type_checks:
+ typecheck, typename = type_checks[self.subclass_of]
+ return """
+ if (!{typecheck}({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "{typename}", {argname});
+ goto exit;
+ }}}}
+ {paramname} = {cast}{argname};
+ """.format(argname=argname, paramname=self.name,
+ typecheck=typecheck, typename=typename, cast=cast)
+ return """
+ if (!PyObject_TypeCheck({argname}, {subclass_of})) {{{{
+ _PyArg_BadArgument("{{name}}", ({subclass_of})->tp_name, {argname});
+ goto exit;
+ }}}}
+ {paramname} = {cast}{argname};
+ """.format(argname=argname, paramname=self.name,
+ subclass_of=self.subclass_of, cast=cast)
+ return """
+ if (!PyArg_Parse(%s, "{format_units}:{name}", {parse_arguments})) {{
+ goto exit;
+ }}
+ """ % argname
+
+type_checks = {
+ '&PyLong_Type': ('PyLong_Check', 'int'),
+ '&PyTuple_Type': ('PyTuple_Check', 'tuple'),
+ '&PyList_Type': ('PyList_Check', 'list'),
+ '&PySet_Type': ('PySet_Check', 'set'),
+ '&PyFrozenSet_Type': ('PyFrozenSet_Check', 'frozenset'),
+ '&PyDict_Type': ('PyDict_Check', 'dict'),
+ '&PyUnicode_Type': ('PyUnicode_Check', 'str'),
+ '&PyBytes_Type': ('PyBytes_Check', 'bytes'),
+ '&PyByteArray_Type': ('PyByteArray_Check', 'bytearray'),
+}
+
class bool_converter(CConverter):
type = 'int'
self.default = bool(self.default)
self.c_default = str(int(self.default))
+ def parse_arg(self, argname):
+ if self.format_unit == 'i':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {paramname} = _PyLong_AsInt({argname});
+ if ({paramname} == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ elif self.format_unit == 'p':
+ return """
+ {paramname} = PyObject_IsTrue({argname});
+ if ({paramname} < 0) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class char_converter(CConverter):
type = 'char'
default_type = (bytes, bytearray)
if self.c_default == '"\'"':
self.c_default = r"'\''"
+ def parse_arg(self, argname):
+ if self.format_unit == 'c':
+ return """
+ if (PyBytes_Check({argname}) && PyBytes_GET_SIZE({argname}) == 1) {{{{
+ {paramname} = PyBytes_AS_STRING({argname})[0];
+ }}}}
+ else if (PyByteArray_Check({argname}) && PyByteArray_GET_SIZE({argname}) == 1) {{{{
+ {paramname} = PyByteArray_AS_STRING({argname})[0];
+ }}}}
+ else {{{{
+ _PyArg_BadArgument("{{name}}", "a byte string of length 1", {argname});
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
@add_legacy_c_converter('B', bitwise=True)
class unsigned_char_converter(CConverter):
if bitwise:
self.format_unit = 'B'
+ def parse_arg(self, argname):
+ if self.format_unit == 'b':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {{{{
+ long ival = PyLong_AsLong({argname});
+ 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 {{{{
+ {paramname} = (unsigned char) ival;
+ }}}}
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ elif self.format_unit == 'B':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {{{{
+ long ival = PyLong_AsUnsignedLongMask({argname});
+ if (ival == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ else {{{{
+ {paramname} = (unsigned char) ival;
+ }}}}
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class byte_converter(unsigned_char_converter): pass
class short_converter(CConverter):
format_unit = 'h'
c_ignored_default = "0"
+ def parse_arg(self, argname):
+ if self.format_unit == 'h':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {{{{
+ long ival = PyLong_AsLong({argname});
+ 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 {{{{
+ {paramname} = (short) ival;
+ }}}}
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class unsigned_short_converter(CConverter):
type = 'unsigned short'
default_type = int
if type != None:
self.type = type
+ def parse_arg(self, argname):
+ if self.format_unit == 'i':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {paramname} = _PyLong_AsInt({argname});
+ if ({paramname} == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ elif self.format_unit == 'C':
+ return """
+ if (!PyUnicode_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "a unicode character", {argname});
+ goto exit;
+ }}}}
+ if (PyUnicode_READY({argname})) {{{{
+ goto exit;
+ }}}}
+ if (PyUnicode_GET_LENGTH({argname}) != 1) {{{{
+ _PyArg_BadArgument("{{name}}", "a unicode character", {argname});
+ goto exit;
+ }}}}
+ {paramname} = PyUnicode_READ_CHAR({argname}, 0);
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class unsigned_int_converter(CConverter):
type = 'unsigned int'
default_type = int
else:
self.converter = '_PyLong_UnsignedInt_Converter'
+ def parse_arg(self, argname):
+ if self.format_unit == 'I':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {paramname} = (unsigned int)PyLong_AsUnsignedLongMask({argname});
+ if ({paramname} == (unsigned int)-1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class long_converter(CConverter):
type = 'long'
default_type = int
format_unit = 'l'
c_ignored_default = "0"
+ def parse_arg(self, argname):
+ if self.format_unit == 'l':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {paramname} = PyLong_AsLong({argname});
+ if ({paramname} == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class unsigned_long_converter(CConverter):
type = 'unsigned long'
default_type = int
else:
self.converter = '_PyLong_UnsignedLong_Converter'
+ def parse_arg(self, argname):
+ if self.format_unit == 'k':
+ return """
+ if (!PyLong_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "int", {argname});
+ goto exit;
+ }}}}
+ {paramname} = PyLong_AsUnsignedLongMask({argname});
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class long_long_converter(CConverter):
type = 'long long'
default_type = int
format_unit = 'L'
c_ignored_default = "0"
+ def parse_arg(self, argname):
+ if self.format_unit == 'L':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {paramname} = PyLong_AsLongLong({argname});
+ if ({paramname} == (PY_LONG_LONG)-1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class unsigned_long_long_converter(CConverter):
type = 'unsigned long long'
default_type = int
else:
self.converter = '_PyLong_UnsignedLongLong_Converter'
+ def parse_arg(self, argname):
+ if self.format_unit == 'K':
+ return """
+ if (!PyLong_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "int", {argname});
+ goto exit;
+ }}}}
+ {paramname} = PyLong_AsUnsignedLongLongMask({argname});
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class Py_ssize_t_converter(CConverter):
type = 'Py_ssize_t'
c_ignored_default = "0"
else:
fail("Py_ssize_t_converter: illegal 'accept' argument " + repr(accept))
+ def parse_arg(self, argname):
+ if self.format_unit == 'n':
+ return """
+ if (PyFloat_Check({argname})) {{{{
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }}}}
+ {{{{
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index({argname});
+ if (iobj != NULL) {{{{
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }}}}
+ if (ival == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ {paramname} = ival;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class slice_index_converter(CConverter):
type = 'Py_ssize_t'
converter = '_PyLong_Size_t_Converter'
c_ignored_default = "0"
+ def parse_arg(self, argname):
+ if self.format_unit == 'n':
+ return """
+ {paramname} = PyNumber_AsSsize_t({argname}, PyExc_OverflowError);
+ if ({paramname} == -1 && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class float_converter(CConverter):
type = 'float'
format_unit = 'f'
c_ignored_default = "0.0"
+ def parse_arg(self, argname):
+ if self.format_unit == 'f':
+ return """
+ {paramname} = (float) PyFloat_AsDouble({argname});
+ if (PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class double_converter(CConverter):
type = 'double'
default_type = float
format_unit = 'd'
c_ignored_default = "0.0"
+ def parse_arg(self, argname):
+ if self.format_unit == 'd':
+ return """
+ {paramname} = PyFloat_AsDouble({argname});
+ if (PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class Py_complex_converter(CConverter):
type = 'Py_complex'
format_unit = 'D'
c_ignored_default = "{0.0, 0.0}"
+ def parse_arg(self, argname):
+ if self.format_unit == 'D':
+ return """
+ {paramname} = PyComplex_AsCComplex({argname});
+ if (PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
class object_converter(CConverter):
type = 'PyObject *'
def cleanup(self):
if self.encoding:
- name = ensure_legal_c_identifier(self.name)
+ name = self.name
return "".join(["if (", name, ") {\n PyMem_FREE(", name, ");\n}\n"])
+ def parse_arg(self, argname):
+ if self.format_unit == 's':
+ return """
+ if (!PyUnicode_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "str", {argname});
+ goto exit;
+ }}}}
+ Py_ssize_t {paramname}_length;
+ {paramname} = PyUnicode_AsUTF8AndSize({argname}, &{paramname}_length);
+ if ({paramname} == NULL) {{{{
+ goto exit;
+ }}}}
+ if (strlen({paramname}) != (size_t){paramname}_length) {{{{
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
#
# This is the fourth or fifth rewrite of registering all the
# string converter format units. Previous approaches hid
format_unit = 'S'
# accept = {bytes}
+ def parse_arg(self, argname):
+ if self.format_unit == 'S':
+ return """
+ if (!PyBytes_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "bytes", {argname});
+ goto exit;
+ }}}}
+ {paramname} = ({type}){argname};
+ """.format(argname=argname, paramname=self.name, type=self.type)
+ return super().parse_arg(argname)
+
class PyByteArrayObject_converter(CConverter):
type = 'PyByteArrayObject *'
format_unit = 'Y'
# accept = {bytearray}
+ def parse_arg(self, argname):
+ if self.format_unit == 'Y':
+ return """
+ if (!PyByteArray_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "bytearray", {argname});
+ goto exit;
+ }}}}
+ {paramname} = ({type}){argname};
+ """.format(argname=argname, paramname=self.name, type=self.type)
+ return super().parse_arg(argname)
+
class unicode_converter(CConverter):
type = 'PyObject *'
default_type = (str, Null, NoneType)
format_unit = 'U'
+ def parse_arg(self, argname):
+ if self.format_unit == 'U':
+ return """
+ if (!PyUnicode_Check({argname})) {{{{
+ _PyArg_BadArgument("{{name}}", "str", {argname});
+ goto exit;
+ }}}}
+ if (PyUnicode_READY({argname}) == -1) {{{{
+ goto exit;
+ }}}}
+ {paramname} = {argname};
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
@add_legacy_c_converter('u#', zeroes=True)
@add_legacy_c_converter('Z', accept={str, NoneType})
@add_legacy_c_converter('Z#', accept={str, NoneType}, zeroes=True)
self.format_unit = format_unit
def cleanup(self):
- name = ensure_legal_c_identifier(self.name)
+ name = self.name
return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
+ def parse_arg(self, argname):
+ if self.format_unit == 'y*':
+ return """
+ if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
+ goto exit;
+ }}}}
+ if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
+ _PyArg_BadArgument("{{name}}", "contiguous buffer", {argname});
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ elif self.format_unit == 's*':
+ return """
+ if (PyUnicode_Check({argname})) {{{{
+ Py_ssize_t len;
+ const char *ptr = PyUnicode_AsUTF8AndSize({argname}, &len);
+ if (ptr == NULL) {{{{
+ goto exit;
+ }}}}
+ PyBuffer_FillInfo(&{paramname}, {argname}, (void *)ptr, len, 1, 0);
+ }}}}
+ else {{{{ /* any bytes-like object */
+ if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
+ goto exit;
+ }}}}
+ if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
+ _PyArg_BadArgument("{{name}}", "contiguous buffer", {argname});
+ goto exit;
+ }}}}
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ elif self.format_unit == 'w*':
+ return """
+ if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_WRITABLE) < 0) {{{{
+ PyErr_Clear();
+ _PyArg_BadArgument("{{name}}", "read-write bytes-like object", {argname});
+ goto exit;
+ }}}}
+ if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
+ _PyArg_BadArgument("{{name}}", "contiguous buffer", {argname});
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.name)
+ return super().parse_arg(argname)
+
def correct_name_for_self(f):
if f.kind in (CALLABLE, METHOD_INIT):