bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
This commit is contained in:
parent
65ce60aef1
commit
32d96a2b5b
|
@ -66,6 +66,8 @@ PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
|
|||
#define _PyArg_NoPositional(funcname, args) \
|
||||
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
|
||||
|
||||
PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, PyObject *);
|
||||
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
|
||||
|
|
|
@ -201,9 +201,11 @@ test_PyBytesObject_converter(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyBytesObject *a;
|
||||
|
||||
if (!PyArg_Parse(arg, "S:test_PyBytesObject_converter", &a)) {
|
||||
if (!PyBytes_Check(arg)) {
|
||||
_PyArg_BadArgument("test_PyBytesObject_converter", "bytes", arg);
|
||||
goto exit;
|
||||
}
|
||||
a = (PyBytesObject *)arg;
|
||||
return_value = test_PyBytesObject_converter_impl(module, a);
|
||||
|
||||
exit:
|
||||
|
@ -212,7 +214,7 @@ exit:
|
|||
|
||||
static PyObject *
|
||||
test_PyBytesObject_converter_impl(PyObject *module, PyBytesObject *a)
|
||||
/*[clinic end generated code: output=8dbf43c604ced031 input=12b10c7cb5750400]*/
|
||||
/*[clinic end generated code: output=fd69d6df4d26c853 input=12b10c7cb5750400]*/
|
||||
|
||||
/*[clinic input]
|
||||
test_PyByteArrayObject_converter
|
||||
|
@ -239,9 +241,11 @@ test_PyByteArrayObject_converter(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyByteArrayObject *a;
|
||||
|
||||
if (!PyArg_Parse(arg, "Y:test_PyByteArrayObject_converter", &a)) {
|
||||
if (!PyByteArray_Check(arg)) {
|
||||
_PyArg_BadArgument("test_PyByteArrayObject_converter", "bytearray", arg);
|
||||
goto exit;
|
||||
}
|
||||
a = (PyByteArrayObject *)arg;
|
||||
return_value = test_PyByteArrayObject_converter_impl(module, a);
|
||||
|
||||
exit:
|
||||
|
@ -250,7 +254,7 @@ exit:
|
|||
|
||||
static PyObject *
|
||||
test_PyByteArrayObject_converter_impl(PyObject *module, PyByteArrayObject *a)
|
||||
/*[clinic end generated code: output=ade99fc6705e7d6e input=5a657da535d194ae]*/
|
||||
/*[clinic end generated code: output=d309c909182c4183 input=5a657da535d194ae]*/
|
||||
|
||||
/*[clinic input]
|
||||
test_unicode_converter
|
||||
|
@ -277,9 +281,14 @@ test_unicode_converter(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *a;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:test_unicode_converter", &a)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("test_unicode_converter", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
a = arg;
|
||||
return_value = test_unicode_converter_impl(module, a);
|
||||
|
||||
exit:
|
||||
|
@ -288,7 +297,7 @@ exit:
|
|||
|
||||
static PyObject *
|
||||
test_unicode_converter_impl(PyObject *module, PyObject *a)
|
||||
/*[clinic end generated code: output=504a2c8d00370adf input=aa33612df92aa9c5]*/
|
||||
/*[clinic end generated code: output=ca603454e1f8f764 input=aa33612df92aa9c5]*/
|
||||
|
||||
/*[clinic input]
|
||||
test_bool_converter
|
||||
|
@ -1027,7 +1036,8 @@ test_Py_complex_converter(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_complex a;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:test_Py_complex_converter", &a)) {
|
||||
a = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = test_Py_complex_converter_impl(module, a);
|
||||
|
@ -1038,7 +1048,7 @@ exit:
|
|||
|
||||
static PyObject *
|
||||
test_Py_complex_converter_impl(PyObject *module, Py_complex a)
|
||||
/*[clinic end generated code: output=27efb4ff772d6170 input=070f216a515beb79]*/
|
||||
/*[clinic end generated code: output=c2ecbec2144ca540 input=070f216a515beb79]*/
|
||||
|
||||
/*[clinic input]
|
||||
test_str_converter
|
||||
|
|
|
@ -19,7 +19,13 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);
|
||||
|
@ -50,7 +56,13 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto1", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);
|
||||
|
@ -183,7 +195,13 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__Buffered_readinto_impl(self, &buffer);
|
||||
|
@ -214,7 +232,13 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto1", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__Buffered_readinto1_impl(self, &buffer);
|
||||
|
@ -390,7 +414,11 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:write", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("write", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io_BufferedWriter_write_impl(self, &buffer);
|
||||
|
@ -476,4 +504,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=cb4bf8d50533953b input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -296,7 +296,13 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io_BytesIO_readinto_impl(self, &buffer);
|
||||
|
@ -444,4 +450,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=89538a941ae1267a input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/
|
||||
|
|
|
@ -156,7 +156,13 @@ _io_FileIO_readinto(fileio *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io_FileIO_readinto_impl(self, &buffer);
|
||||
|
@ -245,7 +251,11 @@ _io_FileIO_write(fileio *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer b = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:write", &b)) {
|
||||
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&b, 'C')) {
|
||||
_PyArg_BadArgument("write", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io_FileIO_write_impl(self, &b);
|
||||
|
@ -373,4 +383,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
|
|||
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
|
||||
#define _IO_FILEIO_TRUNCATE_METHODDEF
|
||||
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
|
||||
/*[clinic end generated code: output=9d44e7035bce105d input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=8be0ea9a5ac7aa43 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -250,9 +250,14 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *text;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:write", &text)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("write", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
text = arg;
|
||||
return_value = _io_TextIOWrapper_write_impl(self, text);
|
||||
|
||||
exit:
|
||||
|
@ -504,4 +509,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return _io_TextIOWrapper_close_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=a811badd76bfe92e input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/
|
||||
|
|
|
@ -156,7 +156,13 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {
|
||||
PyErr_Clear();
|
||||
_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("readinto", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer);
|
||||
|
@ -255,7 +261,11 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer b = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:write", &b)) {
|
||||
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&b, 'C')) {
|
||||
_PyArg_BadArgument("write", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _io__WindowsConsoleIO_write_impl(self, &b);
|
||||
|
@ -328,4 +338,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
|
|||
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
|
||||
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
|
||||
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
|
||||
/*[clinic end generated code: output=080af41338394b49 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=4337e8de65915a1e input=a9049054013a1b77]*/
|
||||
|
|
|
@ -83,7 +83,7 @@ _sha3_shake_128_digest(SHA3object *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
unsigned long length;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:digest", _PyLong_UnsignedLong_Converter, &length)) {
|
||||
if (!_PyLong_UnsignedLong_Converter(arg, &length)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sha3_shake_128_digest_impl(self, length);
|
||||
|
@ -110,7 +110,7 @@ _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
unsigned long length;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:hexdigest", _PyLong_UnsignedLong_Converter, &length)) {
|
||||
if (!_PyLong_UnsignedLong_Converter(arg, &length)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sha3_shake_128_hexdigest_impl(self, length);
|
||||
|
@ -118,4 +118,4 @@ _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=bf823532a7bffe68 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=5b3e99b9a96471e8 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -96,7 +96,7 @@ class cache_struct_converter(CConverter):
|
|||
[python start generated code]*/
|
||||
/*[python end generated code: output=da39a3ee5e6b4b0d input=49957cca130ffb63]*/
|
||||
|
||||
static int cache_struct_converter(PyObject *, PyObject **);
|
||||
static int cache_struct_converter(PyObject *, PyStructObject **);
|
||||
|
||||
#include "clinic/_struct.c.h"
|
||||
|
||||
|
@ -2072,7 +2072,7 @@ PyTypeObject PyStructType = {
|
|||
static PyObject *cache = NULL;
|
||||
|
||||
static int
|
||||
cache_struct_converter(PyObject *fmt, PyObject **ptr)
|
||||
cache_struct_converter(PyObject *fmt, PyStructObject **ptr)
|
||||
{
|
||||
PyObject * s_object;
|
||||
|
||||
|
@ -2091,7 +2091,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr)
|
|||
s_object = PyDict_GetItem(cache, fmt);
|
||||
if (s_object != NULL) {
|
||||
Py_INCREF(s_object);
|
||||
*ptr = s_object;
|
||||
*ptr = (PyStructObject *)s_object;
|
||||
return Py_CLEANUP_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -2102,7 +2102,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr)
|
|||
/* Attempt to cache the result */
|
||||
if (PyDict_SetItem(cache, fmt, s_object) == -1)
|
||||
PyErr_Clear();
|
||||
*ptr = s_object;
|
||||
*ptr = (PyStructObject *)s_object;
|
||||
return Py_CLEANUP_SUPPORTED;
|
||||
}
|
||||
return 0;
|
||||
|
@ -2157,7 +2157,7 @@ pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|||
}
|
||||
format = args[0];
|
||||
|
||||
if (!cache_struct_converter(format, &s_object)) {
|
||||
if (!cache_struct_converter(format, (PyStructObject **)&s_object)) {
|
||||
return NULL;
|
||||
}
|
||||
result = s_pack(s_object, args + 1, nargs - 1);
|
||||
|
@ -2185,7 +2185,7 @@ pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|||
}
|
||||
format = args[0];
|
||||
|
||||
if (!cache_struct_converter(format, &s_object)) {
|
||||
if (!cache_struct_converter(format, (PyStructObject **)&s_object)) {
|
||||
return NULL;
|
||||
}
|
||||
result = s_pack_into(s_object, args + 1, nargs - 1);
|
||||
|
|
|
@ -150,9 +150,11 @@ _multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoder
|
|||
PyObject *return_value = NULL;
|
||||
PyLongObject *statelong;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:setstate", &PyLong_Type, &statelong)) {
|
||||
if (!PyLong_Check(arg)) {
|
||||
_PyArg_BadArgument("setstate", "int", arg);
|
||||
goto exit;
|
||||
}
|
||||
statelong = (PyLongObject *)arg;
|
||||
return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
|
||||
|
||||
exit:
|
||||
|
@ -248,9 +250,11 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoder
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *state;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:setstate", &PyTuple_Type, &state)) {
|
||||
if (!PyTuple_Check(arg)) {
|
||||
_PyArg_BadArgument("setstate", "tuple", arg);
|
||||
goto exit;
|
||||
}
|
||||
state = arg;
|
||||
return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
|
||||
|
||||
exit:
|
||||
|
@ -418,4 +422,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
|
|||
|
||||
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
|
||||
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
|
||||
/*[clinic end generated code: output=4c1dc8015ee5abb4 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=a94364d0965adf1d input=a9049054013a1b77]*/
|
||||
|
|
|
@ -25,7 +25,11 @@ _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:compress", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("compress", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _bz2_BZ2Compressor_compress_impl(self, &data);
|
||||
|
@ -174,4 +178,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=e47f4255d265b07d input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=8549cccdb82f57d9 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -33,7 +33,17 @@ _codecs_lookup(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *encoding;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:lookup", &encoding)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("lookup", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t encoding_length;
|
||||
encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length);
|
||||
if (encoding == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(encoding) != (size_t)encoding_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _codecs_lookup_impl(module, encoding);
|
||||
|
@ -138,7 +148,17 @@ _codecs__forget_codec(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *encoding;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:_forget_codec", &encoding)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("_forget_codec", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t encoding_length;
|
||||
encoding = PyUnicode_AsUTF8AndSize(arg, &encoding_length);
|
||||
if (encoding == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(encoding) != (size_t)encoding_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _codecs__forget_codec_impl(module, encoding);
|
||||
|
@ -1342,9 +1362,14 @@ _codecs_charmap_build(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *map;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:charmap_build", &map)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("charmap_build", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
map = arg;
|
||||
return_value = _codecs_charmap_build_impl(module, map);
|
||||
|
||||
exit:
|
||||
|
@ -1504,7 +1529,17 @@ _codecs_lookup_error(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:lookup_error", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("lookup_error", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t name_length;
|
||||
name = PyUnicode_AsUTF8AndSize(arg, &name_length);
|
||||
if (name == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(name) != (size_t)name_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _codecs_lookup_error_impl(module, name);
|
||||
|
@ -1536,4 +1571,4 @@ exit:
|
|||
#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
|
||||
#define _CODECS_CODE_PAGE_ENCODE_METHODDEF
|
||||
#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
|
||||
/*[clinic end generated code: output=d29fe7c0cb206812 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=c2d2b917b78a4c45 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -196,9 +196,11 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyCursesWindowObject *win;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:replace", &PyCursesWindow_Type, &win)) {
|
||||
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
|
||||
_PyArg_BadArgument("replace", (&PyCursesWindow_Type)->tp_name, arg);
|
||||
goto exit;
|
||||
}
|
||||
win = (PyCursesWindowObject *)arg;
|
||||
return_value = _curses_panel_panel_replace_impl(self, win);
|
||||
|
||||
exit:
|
||||
|
@ -268,9 +270,11 @@ _curses_panel_new_panel(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyCursesWindowObject *win;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:new_panel", &PyCursesWindow_Type, &win)) {
|
||||
if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) {
|
||||
_PyArg_BadArgument("new_panel", (&PyCursesWindow_Type)->tp_name, arg);
|
||||
goto exit;
|
||||
}
|
||||
win = (PyCursesWindowObject *)arg;
|
||||
return_value = _curses_panel_new_panel_impl(module, win);
|
||||
|
||||
exit:
|
||||
|
@ -314,4 +318,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return _curses_panel_update_panels_impl(module);
|
||||
}
|
||||
/*[clinic end generated code: output=66e49cb9726a638f input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=4b211b4015e29100 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -273,7 +273,13 @@ _curses_window_attroff(PyCursesWindowObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
long attr;
|
||||
|
||||
if (!PyArg_Parse(arg, "l:attroff", &attr)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
attr = PyLong_AsLong(arg);
|
||||
if (attr == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_window_attroff_impl(self, attr);
|
||||
|
@ -300,7 +306,13 @@ _curses_window_attron(PyCursesWindowObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
long attr;
|
||||
|
||||
if (!PyArg_Parse(arg, "l:attron", &attr)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
attr = PyLong_AsLong(arg);
|
||||
if (attr == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_window_attron_impl(self, attr);
|
||||
|
@ -327,7 +339,13 @@ _curses_window_attrset(PyCursesWindowObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
long attr;
|
||||
|
||||
if (!PyArg_Parse(arg, "l:attrset", &attr)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
attr = PyLong_AsLong(arg);
|
||||
if (attr == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_window_attrset_impl(self, attr);
|
||||
|
@ -1198,7 +1216,13 @@ _curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int line;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:is_linetouched", &line)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
line = _PyLong_AsInt(arg);
|
||||
if (line == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_window_is_linetouched_impl(self, line);
|
||||
|
@ -1888,9 +1912,30 @@ _curses_color_content(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
short color_number;
|
||||
|
||||
if (!PyArg_Parse(arg, "h:color_content", &color_number)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
long ival = PyLong_AsLong(arg);
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
else if (ival < SHRT_MIN) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"signed short integer is less than minimum");
|
||||
goto exit;
|
||||
}
|
||||
else if (ival > SHRT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"signed short integer is greater than maximum");
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
color_number = (short) ival;
|
||||
}
|
||||
}
|
||||
return_value = _curses_color_content_impl(module, color_number);
|
||||
|
||||
exit:
|
||||
|
@ -1921,9 +1966,30 @@ _curses_color_pair(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
short color_number;
|
||||
|
||||
if (!PyArg_Parse(arg, "h:color_pair", &color_number)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
long ival = PyLong_AsLong(arg);
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
else if (ival < SHRT_MIN) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"signed short integer is less than minimum");
|
||||
goto exit;
|
||||
}
|
||||
else if (ival > SHRT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"signed short integer is greater than maximum");
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
color_number = (short) ival;
|
||||
}
|
||||
}
|
||||
return_value = _curses_color_pair_impl(module, color_number);
|
||||
|
||||
exit:
|
||||
|
@ -1956,7 +2022,13 @@ _curses_curs_set(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int visibility;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:curs_set", &visibility)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
visibility = _PyLong_AsInt(arg);
|
||||
if (visibility == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_curs_set_impl(module, visibility);
|
||||
|
@ -2030,7 +2102,13 @@ _curses_delay_output(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int ms;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:delay_output", &ms)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
ms = _PyLong_AsInt(arg);
|
||||
if (ms == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_delay_output_impl(module, ms);
|
||||
|
@ -2290,9 +2368,30 @@ _curses_halfdelay(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
unsigned char tenths;
|
||||
|
||||
if (!PyArg_Parse(arg, "b:halfdelay", &tenths)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
long ival = PyLong_AsLong(arg);
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
else if (ival < 0) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"unsigned byte integer is less than minimum");
|
||||
goto exit;
|
||||
}
|
||||
else if (ival > UCHAR_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"unsigned byte integer is greater than maximum");
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
tenths = (unsigned char) ival;
|
||||
}
|
||||
}
|
||||
return_value = _curses_halfdelay_impl(module, tenths);
|
||||
|
||||
exit:
|
||||
|
@ -2376,7 +2475,13 @@ _curses_has_key(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int key;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:has_key", &key)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
key = _PyLong_AsInt(arg);
|
||||
if (key == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_has_key_impl(module, key);
|
||||
|
@ -2548,7 +2653,13 @@ _curses_intrflush(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int flag;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:intrflush", &flag)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
flag = _PyLong_AsInt(arg);
|
||||
if (flag == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_intrflush_impl(module, flag);
|
||||
|
@ -2634,7 +2745,13 @@ _curses_keyname(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int key;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:keyname", &key)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
key = _PyLong_AsInt(arg);
|
||||
if (key == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_keyname_impl(module, key);
|
||||
|
@ -2703,7 +2820,13 @@ _curses_meta(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int yes;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:meta", &yes)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
yes = _PyLong_AsInt(arg);
|
||||
if (yes == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_meta_impl(module, yes);
|
||||
|
@ -2739,7 +2862,13 @@ _curses_mouseinterval(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int interval;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:mouseinterval", &interval)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
interval = _PyLong_AsInt(arg);
|
||||
if (interval == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_mouseinterval_impl(module, interval);
|
||||
|
@ -2775,9 +2904,11 @@ _curses_mousemask(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
unsigned long newmask;
|
||||
|
||||
if (!PyArg_Parse(arg, "k:mousemask", &newmask)) {
|
||||
if (!PyLong_Check(arg)) {
|
||||
_PyArg_BadArgument("mousemask", "int", arg);
|
||||
goto exit;
|
||||
}
|
||||
newmask = PyLong_AsUnsignedLongMask(arg);
|
||||
return_value = _curses_mousemask_impl(module, newmask);
|
||||
|
||||
exit:
|
||||
|
@ -2807,7 +2938,13 @@ _curses_napms(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int ms;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:napms", &ms)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
ms = _PyLong_AsInt(arg);
|
||||
if (ms == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_napms_impl(module, ms);
|
||||
|
@ -3062,9 +3199,30 @@ _curses_pair_content(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
short pair_number;
|
||||
|
||||
if (!PyArg_Parse(arg, "h:pair_content", &pair_number)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
long ival = PyLong_AsLong(arg);
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
else if (ival < SHRT_MIN) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"signed short integer is less than minimum");
|
||||
goto exit;
|
||||
}
|
||||
else if (ival > SHRT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"signed short integer is greater than maximum");
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
pair_number = (short) ival;
|
||||
}
|
||||
}
|
||||
return_value = _curses_pair_content_impl(module, pair_number);
|
||||
|
||||
exit:
|
||||
|
@ -3091,7 +3249,13 @@ _curses_pair_number(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int attr;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:pair_number", &attr)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
attr = _PyLong_AsInt(arg);
|
||||
if (attr == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_pair_number_impl(module, attr);
|
||||
|
@ -3511,7 +3675,17 @@ _curses_tigetflag(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *capname;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:tigetflag", &capname)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("tigetflag", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t capname_length;
|
||||
capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
|
||||
if (capname == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(capname) != (size_t)capname_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_tigetflag_impl(module, capname);
|
||||
|
@ -3544,7 +3718,17 @@ _curses_tigetnum(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *capname;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:tigetnum", &capname)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("tigetnum", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t capname_length;
|
||||
capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
|
||||
if (capname == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(capname) != (size_t)capname_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_tigetnum_impl(module, capname);
|
||||
|
@ -3577,7 +3761,17 @@ _curses_tigetstr(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *capname;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:tigetstr", &capname)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("tigetstr", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t capname_length;
|
||||
capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
|
||||
if (capname == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(capname) != (size_t)capname_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_tigetstr_impl(module, capname);
|
||||
|
@ -3653,7 +3847,13 @@ _curses_typeahead(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:typeahead", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_typeahead_impl(module, fd);
|
||||
|
@ -3727,7 +3927,13 @@ _curses_use_env(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int flag;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:use_env", &flag)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
flag = _PyLong_AsInt(arg);
|
||||
if (flag == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _curses_use_env_impl(module, flag);
|
||||
|
@ -3838,4 +4044,4 @@ _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
|
||||
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
|
||||
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
|
||||
/*[clinic end generated code: output=177ad1d0b5586aaa input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=a2bbced3c5d29d64 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -19,9 +19,11 @@ _elementtree_Element_append(ElementObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *subelement;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:append", &Element_Type, &subelement)) {
|
||||
if (!PyObject_TypeCheck(arg, &Element_Type)) {
|
||||
_PyArg_BadArgument("append", (&Element_Type)->tp_name, arg);
|
||||
goto exit;
|
||||
}
|
||||
subelement = arg;
|
||||
return_value = _elementtree_Element_append_impl(self, subelement);
|
||||
|
||||
exit:
|
||||
|
@ -79,9 +81,11 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *memo;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:__deepcopy__", &PyDict_Type, &memo)) {
|
||||
if (!PyDict_Check(arg)) {
|
||||
_PyArg_BadArgument("__deepcopy__", "dict", arg);
|
||||
goto exit;
|
||||
}
|
||||
memo = arg;
|
||||
return_value = _elementtree_Element___deepcopy___impl(self, memo);
|
||||
|
||||
exit:
|
||||
|
@ -507,9 +511,11 @@ _elementtree_Element_remove(ElementObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *subelement;
|
||||
|
||||
if (!PyArg_Parse(arg, "O!:remove", &Element_Type, &subelement)) {
|
||||
if (!PyObject_TypeCheck(arg, &Element_Type)) {
|
||||
_PyArg_BadArgument("remove", (&Element_Type)->tp_name, arg);
|
||||
goto exit;
|
||||
}
|
||||
subelement = arg;
|
||||
return_value = _elementtree_Element_remove_impl(self, subelement);
|
||||
|
||||
exit:
|
||||
|
@ -717,4 +723,4 @@ _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args,
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=f1efdb511a5b027b input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=398640585689c5ed input=a9049054013a1b77]*/
|
||||
|
|
|
@ -25,7 +25,11 @@ _lzma_LZMACompressor_compress(Compressor *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:compress", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("compress", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _lzma_LZMACompressor_compress_impl(self, &data);
|
||||
|
@ -178,7 +182,13 @@ _lzma_is_check_supported(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int check_id;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:is_check_supported", &check_id)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
check_id = _PyLong_AsInt(arg);
|
||||
if (check_id == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _lzma_is_check_supported_impl(module, check_id);
|
||||
|
@ -207,7 +217,7 @@ _lzma__encode_filter_properties(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
lzma_filter filter = {LZMA_VLI_UNKNOWN, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:_encode_filter_properties", lzma_filter_converter, &filter)) {
|
||||
if (!lzma_filter_converter(arg, &filter)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _lzma__encode_filter_properties_impl(module, filter);
|
||||
|
@ -256,4 +266,4 @@ exit:
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=2acfd7c4b68530a6 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=df061bfc2067a90a input=a9049054013a1b77]*/
|
||||
|
|
|
@ -47,7 +47,13 @@ _sre_ascii_iscased(PyObject *module, PyObject *arg)
|
|||
int character;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:ascii_iscased", &character)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
character = _PyLong_AsInt(arg);
|
||||
if (character == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = _sre_ascii_iscased_impl(module, character);
|
||||
|
@ -78,7 +84,13 @@ _sre_unicode_iscased(PyObject *module, PyObject *arg)
|
|||
int character;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:unicode_iscased", &character)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
character = _PyLong_AsInt(arg);
|
||||
if (character == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = _sre_unicode_iscased_impl(module, character);
|
||||
|
@ -109,7 +121,13 @@ _sre_ascii_tolower(PyObject *module, PyObject *arg)
|
|||
int character;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:ascii_tolower", &character)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
character = _PyLong_AsInt(arg);
|
||||
if (character == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = _sre_ascii_tolower_impl(module, character);
|
||||
|
@ -140,7 +158,13 @@ _sre_unicode_tolower(PyObject *module, PyObject *arg)
|
|||
int character;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:unicode_tolower", &character)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
character = _PyLong_AsInt(arg);
|
||||
if (character == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = _sre_unicode_tolower_impl(module, character);
|
||||
|
@ -765,4 +789,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return _sre_SRE_Scanner_search_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=5edeca5ec36b5f34 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=7992634045212b26 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -36,7 +36,7 @@ _ssl__test_decode_cert(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *path;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:_test_decode_cert", PyUnicode_FSConverter, &path)) {
|
||||
if (!PyUnicode_FSConverter(arg, &path)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl__test_decode_cert_impl(module, path);
|
||||
|
@ -211,7 +211,11 @@ _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer b = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:write", &b)) {
|
||||
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&b, 'C')) {
|
||||
_PyArg_BadArgument("write", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl__SSLSocket_write_impl(self, &b);
|
||||
|
@ -400,7 +404,17 @@ _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *cipherlist;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:set_ciphers", &cipherlist)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("set_ciphers", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t cipherlist_length;
|
||||
cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length);
|
||||
if (cipherlist == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(cipherlist) != (size_t)cipherlist_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist);
|
||||
|
@ -448,7 +462,11 @@ _ssl__SSLContext__set_npn_protocols(PySSLContext *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer protos = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:_set_npn_protocols", &protos)) {
|
||||
if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&protos, 'C')) {
|
||||
_PyArg_BadArgument("_set_npn_protocols", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos);
|
||||
|
@ -480,7 +498,11 @@ _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer protos = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:_set_alpn_protocols", &protos)) {
|
||||
if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&protos, 'C')) {
|
||||
_PyArg_BadArgument("_set_alpn_protocols", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
|
||||
|
@ -823,7 +845,11 @@ _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer b = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:write", &b)) {
|
||||
if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&b, 'C')) {
|
||||
_PyArg_BadArgument("write", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl_MemoryBIO_write_impl(self, &b);
|
||||
|
@ -912,7 +938,13 @@ _ssl_RAND_bytes(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int n;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:RAND_bytes", &n)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
n = _PyLong_AsInt(arg);
|
||||
if (n == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl_RAND_bytes_impl(module, n);
|
||||
|
@ -942,7 +974,13 @@ _ssl_RAND_pseudo_bytes(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int n;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:RAND_pseudo_bytes", &n)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
n = _PyLong_AsInt(arg);
|
||||
if (n == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl_RAND_pseudo_bytes_impl(module, n);
|
||||
|
@ -995,7 +1033,7 @@ _ssl_RAND_egd(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *path;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:RAND_egd", PyUnicode_FSConverter, &path)) {
|
||||
if (!PyUnicode_FSConverter(arg, &path)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl_RAND_egd_impl(module, path);
|
||||
|
@ -1078,7 +1116,13 @@ _ssl_nid2obj(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int nid;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:nid2obj", &nid)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
nid = _PyLong_AsInt(arg);
|
||||
if (nid == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _ssl_nid2obj_impl(module, nid);
|
||||
|
@ -1193,4 +1237,4 @@ exit:
|
|||
#ifndef _SSL_ENUM_CRLS_METHODDEF
|
||||
#define _SSL_ENUM_CRLS_METHODDEF
|
||||
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
|
||||
/*[clinic end generated code: output=d87f783224be8fca input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=c2dca2ef4cbef4e2 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -57,7 +57,11 @@ Struct_unpack(PyStructObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:unpack", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("unpack", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = Struct_unpack_impl(self, &buffer);
|
||||
|
@ -166,7 +170,7 @@ calcsize(PyObject *module, PyObject *arg)
|
|||
PyStructObject *s_object = NULL;
|
||||
Py_ssize_t _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:calcsize", cache_struct_converter, &s_object)) {
|
||||
if (!cache_struct_converter(arg, &s_object)) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = calcsize_impl(module, s_object);
|
||||
|
@ -303,4 +307,4 @@ exit:
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=a73b0453174e4b51 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=01516bea2641fe01 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -19,7 +19,17 @@ _tkinter_tkapp_eval(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *script;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:eval", &script)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("eval", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t script_length;
|
||||
script = PyUnicode_AsUTF8AndSize(arg, &script_length);
|
||||
if (script == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(script) != (size_t)script_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_eval_impl(self, script);
|
||||
|
@ -45,7 +55,17 @@ _tkinter_tkapp_evalfile(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *fileName;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:evalfile", &fileName)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("evalfile", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t fileName_length;
|
||||
fileName = PyUnicode_AsUTF8AndSize(arg, &fileName_length);
|
||||
if (fileName == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(fileName) != (size_t)fileName_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_evalfile_impl(self, fileName);
|
||||
|
@ -71,7 +91,17 @@ _tkinter_tkapp_record(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *script;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:record", &script)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("record", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t script_length;
|
||||
script = PyUnicode_AsUTF8AndSize(arg, &script_length);
|
||||
if (script == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(script) != (size_t)script_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_record_impl(self, script);
|
||||
|
@ -97,7 +127,17 @@ _tkinter_tkapp_adderrorinfo(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *msg;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:adderrorinfo", &msg)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("adderrorinfo", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t msg_length;
|
||||
msg = PyUnicode_AsUTF8AndSize(arg, &msg_length);
|
||||
if (msg == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(msg) != (size_t)msg_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_adderrorinfo_impl(self, msg);
|
||||
|
@ -147,7 +187,17 @@ _tkinter_tkapp_exprstring(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *s;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:exprstring", &s)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("exprstring", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t s_length;
|
||||
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
|
||||
if (s == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(s) != (size_t)s_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_exprstring_impl(self, s);
|
||||
|
@ -173,7 +223,17 @@ _tkinter_tkapp_exprlong(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *s;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:exprlong", &s)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("exprlong", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t s_length;
|
||||
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
|
||||
if (s == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(s) != (size_t)s_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_exprlong_impl(self, s);
|
||||
|
@ -199,7 +259,17 @@ _tkinter_tkapp_exprdouble(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *s;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:exprdouble", &s)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("exprdouble", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t s_length;
|
||||
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
|
||||
if (s == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(s) != (size_t)s_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_exprdouble_impl(self, s);
|
||||
|
@ -225,7 +295,17 @@ _tkinter_tkapp_exprboolean(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *s;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:exprboolean", &s)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("exprboolean", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t s_length;
|
||||
s = PyUnicode_AsUTF8AndSize(arg, &s_length);
|
||||
if (s == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(s) != (size_t)s_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_exprboolean_impl(self, s);
|
||||
|
@ -296,7 +376,17 @@ _tkinter_tkapp_deletecommand(TkappObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:deletecommand", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("deletecommand", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t name_length;
|
||||
name = PyUnicode_AsUTF8AndSize(arg, &name_length);
|
||||
if (name == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(name) != (size_t)name_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_tkapp_deletecommand_impl(self, name);
|
||||
|
@ -594,7 +684,13 @@ _tkinter_setbusywaitinterval(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int new_val;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:setbusywaitinterval", &new_val)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
new_val = _PyLong_AsInt(arg);
|
||||
if (new_val == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _tkinter_setbusywaitinterval_impl(module, new_val);
|
||||
|
@ -638,4 +734,4 @@ exit:
|
|||
#ifndef _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
|
||||
#define _TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF
|
||||
#endif /* !defined(_TKINTER_TKAPP_DELETEFILEHANDLER_METHODDEF) */
|
||||
/*[clinic end generated code: output=a9d45a90cde94980 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=d84b0e794824c511 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -19,7 +19,8 @@ _winapi_Overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int wait;
|
||||
|
||||
if (!PyArg_Parse(arg, "p:GetOverlappedResult", &wait)) {
|
||||
wait = PyObject_IsTrue(arg);
|
||||
if (wait < 0) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _winapi_Overlapped_GetOverlappedResult_impl(self, wait);
|
||||
|
@ -944,4 +945,4 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=145d0d362167c1b1 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=5063c84b2d125488 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -278,8 +278,22 @@ array_array_fromstring(arrayobject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "s*:fromstring", &buffer)) {
|
||||
goto exit;
|
||||
if (PyUnicode_Check(arg)) {
|
||||
Py_ssize_t len;
|
||||
const char *ptr = PyUnicode_AsUTF8AndSize(arg, &len);
|
||||
if (ptr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
PyBuffer_FillInfo(&buffer, arg, (void *)ptr, len, 1, 0);
|
||||
}
|
||||
else { /* any bytes-like object */
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("fromstring", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
return_value = array_array_fromstring_impl(self, &buffer);
|
||||
|
||||
|
@ -310,7 +324,11 @@ array_array_frombytes(arrayobject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer buffer = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:frombytes", &buffer)) {
|
||||
if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&buffer, 'C')) {
|
||||
_PyArg_BadArgument("frombytes", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = array_array_frombytes_impl(self, &buffer);
|
||||
|
@ -505,4 +523,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
|
|||
|
||||
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
|
||||
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
|
||||
/*[clinic end generated code: output=3d2bb1aa81541cbd input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=15da19d2ece09d22 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -20,7 +20,7 @@ binascii_a2b_uu(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:a2b_uu", ascii_buffer_converter, &data)) {
|
||||
if (!ascii_buffer_converter(arg, &data)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_a2b_uu_impl(module, &data);
|
||||
|
@ -87,7 +87,7 @@ binascii_a2b_base64(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:a2b_base64", ascii_buffer_converter, &data)) {
|
||||
if (!ascii_buffer_converter(arg, &data)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_a2b_base64_impl(module, &data);
|
||||
|
@ -154,7 +154,7 @@ binascii_a2b_hqx(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:a2b_hqx", ascii_buffer_converter, &data)) {
|
||||
if (!ascii_buffer_converter(arg, &data)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_a2b_hqx_impl(module, &data);
|
||||
|
@ -185,7 +185,11 @@ binascii_rlecode_hqx(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:rlecode_hqx", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("rlecode_hqx", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_rlecode_hqx_impl(module, &data);
|
||||
|
@ -217,7 +221,11 @@ binascii_b2a_hqx(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:b2a_hqx", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("b2a_hqx", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_b2a_hqx_impl(module, &data);
|
||||
|
@ -249,7 +257,11 @@ binascii_rledecode_hqx(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:rledecode_hqx", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("rledecode_hqx", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_rledecode_hqx_impl(module, &data);
|
||||
|
@ -362,7 +374,11 @@ binascii_b2a_hex(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:b2a_hex", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("b2a_hex", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_b2a_hex_impl(module, &data);
|
||||
|
@ -396,7 +412,11 @@ binascii_hexlify(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:hexlify", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("hexlify", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_hexlify_impl(module, &data);
|
||||
|
@ -431,7 +451,7 @@ binascii_a2b_hex(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer hexstr = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:a2b_hex", ascii_buffer_converter, &hexstr)) {
|
||||
if (!ascii_buffer_converter(arg, &hexstr)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_a2b_hex_impl(module, &hexstr);
|
||||
|
@ -464,7 +484,7 @@ binascii_unhexlify(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer hexstr = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:unhexlify", ascii_buffer_converter, &hexstr)) {
|
||||
if (!ascii_buffer_converter(arg, &hexstr)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = binascii_unhexlify_impl(module, &hexstr);
|
||||
|
@ -554,4 +574,4 @@ exit:
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=3f45e15ce8b563b7 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=8ff0cb5717b15d1b input=a9049054013a1b77]*/
|
||||
|
|
|
@ -21,7 +21,8 @@ cmath_acos(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:acos", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -63,7 +64,8 @@ cmath_acosh(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:acosh", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -105,7 +107,8 @@ cmath_asin(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:asin", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -147,7 +150,8 @@ cmath_asinh(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:asinh", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -189,7 +193,8 @@ cmath_atan(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:atan", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -231,7 +236,8 @@ cmath_atanh(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:atanh", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -273,7 +279,8 @@ cmath_cos(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:cos", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -315,7 +322,8 @@ cmath_cosh(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:cosh", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -357,7 +365,8 @@ cmath_exp(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:exp", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -399,7 +408,8 @@ cmath_log10(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:log10", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -441,7 +451,8 @@ cmath_sin(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:sin", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -483,7 +494,8 @@ cmath_sinh(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:sinh", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -525,7 +537,8 @@ cmath_sqrt(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:sqrt", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -567,7 +580,8 @@ cmath_tan(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:tan", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -609,7 +623,8 @@ cmath_tanh(PyObject *module, PyObject *arg)
|
|||
Py_complex z;
|
||||
Py_complex _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:tanh", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
/* modifications for z */
|
||||
|
@ -681,7 +696,8 @@ cmath_phase(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_complex z;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:phase", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = cmath_phase_impl(module, z);
|
||||
|
@ -710,7 +726,8 @@ cmath_polar(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_complex z;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:polar", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = cmath_polar_impl(module, z);
|
||||
|
@ -766,7 +783,8 @@ cmath_isfinite(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_complex z;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:isfinite", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = cmath_isfinite_impl(module, z);
|
||||
|
@ -793,7 +811,8 @@ cmath_isnan(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_complex z;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:isnan", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = cmath_isnan_impl(module, z);
|
||||
|
@ -820,7 +839,8 @@ cmath_isinf(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_complex z;
|
||||
|
||||
if (!PyArg_Parse(arg, "D:isinf", &z)) {
|
||||
z = PyComplex_AsCComplex(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = cmath_isinf_impl(module, z);
|
||||
|
@ -882,4 +902,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=17f6f65a229b1ef9 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=50a105aa2bc5308f input=a9049054013a1b77]*/
|
||||
|
|
|
@ -136,7 +136,13 @@ gc_set_debug(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int flags;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:set_debug", &flags)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
flags = _PyLong_AsInt(arg);
|
||||
if (flags == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = gc_set_debug_impl(module, flags);
|
||||
|
@ -325,4 +331,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=ba67a1ab58780485 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=5aa5fdc259503d5f input=a9049054013a1b77]*/
|
||||
|
|
|
@ -108,7 +108,8 @@ math_frexp(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:frexp", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_frexp_impl(module, x);
|
||||
|
@ -168,7 +169,8 @@ math_modf(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:modf", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_modf_impl(module, x);
|
||||
|
@ -352,7 +354,8 @@ math_degrees(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:degrees", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_degrees_impl(module, x);
|
||||
|
@ -379,7 +382,8 @@ math_radians(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:radians", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_radians_impl(module, x);
|
||||
|
@ -406,7 +410,8 @@ math_isfinite(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:isfinite", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_isfinite_impl(module, x);
|
||||
|
@ -433,7 +438,8 @@ math_isnan(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:isnan", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_isnan_impl(module, x);
|
||||
|
@ -460,7 +466,8 @@ math_isinf(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
double x;
|
||||
|
||||
if (!PyArg_Parse(arg, "d:isinf", &x)) {
|
||||
x = PyFloat_AsDouble(arg);
|
||||
if (PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = math_isinf_impl(module, x);
|
||||
|
@ -523,4 +530,4 @@ math_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=8b1709a71e5fb855 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=da4b9940a5cb0188 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -185,7 +185,13 @@ os_ttyname(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:ttyname", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_ttyname_impl(module, fd);
|
||||
|
@ -941,7 +947,7 @@ os__getfullpathname(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
path_t path = PATH_T_INITIALIZE("_getfullpathname", "path", 0, 0);
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:_getfullpathname", path_converter, &path)) {
|
||||
if (!path_converter(arg, &path)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os__getfullpathname_impl(module, &path);
|
||||
|
@ -975,7 +981,7 @@ os__getfinalpathname(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
path_t path = PATH_T_INITIALIZE("_getfinalpathname", "path", 0, 0);
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:_getfinalpathname", path_converter, &path)) {
|
||||
if (!path_converter(arg, &path)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os__getfinalpathname_impl(module, &path);
|
||||
|
@ -1101,7 +1107,13 @@ os_nice(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int increment;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:nice", &increment)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
increment = _PyLong_AsInt(arg);
|
||||
if (increment == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_nice_impl(module, increment);
|
||||
|
@ -1411,7 +1423,13 @@ os_umask(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int mask;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:umask", &mask)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
mask = _PyLong_AsInt(arg);
|
||||
if (mask == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_umask_impl(module, mask);
|
||||
|
@ -2725,7 +2743,13 @@ os_plock(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int op;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:plock", &op)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
op = _PyLong_AsInt(arg);
|
||||
if (op == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_plock_impl(module, op);
|
||||
|
@ -2756,7 +2780,7 @@ os_setuid(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
uid_t uid;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:setuid", _Py_Uid_Converter, &uid)) {
|
||||
if (!_Py_Uid_Converter(arg, &uid)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_setuid_impl(module, uid);
|
||||
|
@ -2787,7 +2811,7 @@ os_seteuid(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
uid_t euid;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:seteuid", _Py_Uid_Converter, &euid)) {
|
||||
if (!_Py_Uid_Converter(arg, &euid)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_seteuid_impl(module, euid);
|
||||
|
@ -2818,7 +2842,7 @@ os_setegid(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
gid_t egid;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:setegid", _Py_Gid_Converter, &egid)) {
|
||||
if (!_Py_Gid_Converter(arg, &egid)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_setegid_impl(module, egid);
|
||||
|
@ -2915,7 +2939,7 @@ os_setgid(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
gid_t gid;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:setgid", _Py_Gid_Converter, &gid)) {
|
||||
if (!_Py_Gid_Converter(arg, &gid)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_setgid_impl(module, gid);
|
||||
|
@ -3389,7 +3413,13 @@ os_tcgetpgrp(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:tcgetpgrp", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_tcgetpgrp_impl(module, fd);
|
||||
|
@ -3557,7 +3587,13 @@ os_dup(PyObject *module, PyObject *arg)
|
|||
int fd;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:dup", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_dup_impl(module, fd);
|
||||
|
@ -3981,7 +4017,13 @@ os_isatty(PyObject *module, PyObject *arg)
|
|||
int fd;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:isatty", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_isatty_impl(module, fd);
|
||||
|
@ -4045,7 +4087,13 @@ os_pipe2(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int flags;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:pipe2", &flags)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
flags = _PyLong_AsInt(arg);
|
||||
if (flags == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_pipe2_impl(module, flags);
|
||||
|
@ -4318,7 +4366,7 @@ os_major(PyObject *module, PyObject *arg)
|
|||
dev_t device;
|
||||
unsigned int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:major", _Py_Dev_Converter, &device)) {
|
||||
if (!_Py_Dev_Converter(arg, &device)) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_major_impl(module, device);
|
||||
|
@ -4354,7 +4402,7 @@ os_minor(PyObject *module, PyObject *arg)
|
|||
dev_t device;
|
||||
unsigned int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:minor", _Py_Dev_Converter, &device)) {
|
||||
if (!_Py_Dev_Converter(arg, &device)) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_minor_impl(module, device);
|
||||
|
@ -4654,7 +4702,7 @@ os_unsetenv(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name = NULL;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:unsetenv", PyUnicode_FSConverter, &name)) {
|
||||
if (!PyUnicode_FSConverter(arg, &name)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_unsetenv_impl(module, name);
|
||||
|
@ -4686,7 +4734,13 @@ os_strerror(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int code;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:strerror", &code)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
code = _PyLong_AsInt(arg);
|
||||
if (code == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_strerror_impl(module, code);
|
||||
|
@ -4716,7 +4770,13 @@ os_WCOREDUMP(PyObject *module, PyObject *arg)
|
|||
int status;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:WCOREDUMP", &status)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
status = _PyLong_AsInt(arg);
|
||||
if (status == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_WCOREDUMP_impl(module, status);
|
||||
|
@ -5029,7 +5089,13 @@ os_fstatvfs(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:fstatvfs", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_fstatvfs_impl(module, fd);
|
||||
|
@ -5225,7 +5291,7 @@ os_confstr(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int name;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:confstr", conv_confstr_confname, &name)) {
|
||||
if (!conv_confstr_confname(arg, &name)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = os_confstr_impl(module, name);
|
||||
|
@ -5257,7 +5323,7 @@ os_sysconf(PyObject *module, PyObject *arg)
|
|||
int name;
|
||||
long _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:sysconf", conv_sysconf_confname, &name)) {
|
||||
if (!conv_sysconf_confname(arg, &name)) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_sysconf_impl(module, name);
|
||||
|
@ -5730,9 +5796,23 @@ os_urandom(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_ssize_t size;
|
||||
|
||||
if (!PyArg_Parse(arg, "n:urandom", &size)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(arg);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
size = ival;
|
||||
}
|
||||
return_value = os_urandom_impl(module, size);
|
||||
|
||||
exit:
|
||||
|
@ -5780,7 +5860,13 @@ os_get_inheritable(PyObject *module, PyObject *arg)
|
|||
int fd;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:get_inheritable", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_get_inheritable_impl(module, fd);
|
||||
|
@ -5915,7 +6001,13 @@ os_get_blocking(PyObject *module, PyObject *arg)
|
|||
int fd;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:get_blocking", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = os_get_blocking_impl(module, fd);
|
||||
|
@ -6753,4 +6845,4 @@ exit:
|
|||
#ifndef OS_GETRANDOM_METHODDEF
|
||||
#define OS_GETRANDOM_METHODDEF
|
||||
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
|
||||
/*[clinic end generated code: output=87a3ebadb91bc46b input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=b02036b2a269b1db input=a9049054013a1b77]*/
|
||||
|
|
|
@ -33,9 +33,14 @@ pwd_getpwnam(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:getpwnam", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("getpwnam", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = pwd_getpwnam_impl(module, name);
|
||||
|
||||
exit:
|
||||
|
@ -69,4 +74,4 @@ pwd_getpwall(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
#ifndef PWD_GETPWALL_METHODDEF
|
||||
#define PWD_GETPWALL_METHODDEF
|
||||
#endif /* !defined(PWD_GETPWALL_METHODDEF) */
|
||||
/*[clinic end generated code: output=3c93120d6dd86905 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=9e86e23d6ad9cd08 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -61,7 +61,17 @@ pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *base;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:SetBase", &base)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("SetBase", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t base_length;
|
||||
base = PyUnicode_AsUTF8AndSize(arg, &base_length);
|
||||
if (base == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(base) != (size_t)base_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = pyexpat_xmlparser_SetBase_impl(self, base);
|
||||
|
@ -163,7 +173,13 @@ pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int flag;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:SetParamEntityParsing", &flag)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
flag = _PyLong_AsInt(arg);
|
||||
if (flag == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
|
||||
|
@ -260,7 +276,13 @@ pyexpat_ErrorString(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
long code;
|
||||
|
||||
if (!PyArg_Parse(arg, "l:ErrorString", &code)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
code = PyLong_AsLong(arg);
|
||||
if (code == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = pyexpat_ErrorString_impl(module, code);
|
||||
|
@ -272,4 +294,4 @@ exit:
|
|||
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
|
||||
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
|
||||
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
|
||||
/*[clinic end generated code: output=c390207761c679d3 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=d3750256eb0da1cb input=a9049054013a1b77]*/
|
||||
|
|
|
@ -19,7 +19,13 @@ resource_getrusage(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int who;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:getrusage", &who)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
who = _PyLong_AsInt(arg);
|
||||
if (who == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = resource_getrusage_impl(module, who);
|
||||
|
@ -45,7 +51,13 @@ resource_getrlimit(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int resource;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:getrlimit", &resource)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
resource = _PyLong_AsInt(arg);
|
||||
if (resource == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = resource_getrlimit_impl(module, resource);
|
||||
|
@ -157,4 +169,4 @@ exit:
|
|||
#ifndef RESOURCE_PRLIMIT_METHODDEF
|
||||
#define RESOURCE_PRLIMIT_METHODDEF
|
||||
#endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */
|
||||
/*[clinic end generated code: output=637ed2c42bde5ca6 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=b16a9149639081fd input=a9049054013a1b77]*/
|
||||
|
|
|
@ -153,7 +153,7 @@ select_poll_unregister(pollObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:unregister", fildes_converter, &fd)) {
|
||||
if (!fildes_converter(arg, &fd)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = select_poll_unregister_impl(self, fd);
|
||||
|
@ -300,7 +300,7 @@ select_devpoll_unregister(devpollObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:unregister", fildes_converter, &fd)) {
|
||||
if (!fildes_converter(arg, &fd)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = select_devpoll_unregister_impl(self, fd);
|
||||
|
@ -550,7 +550,13 @@ select_epoll_fromfd(PyTypeObject *type, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:fromfd", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = select_epoll_fromfd_impl(type, fd);
|
||||
|
@ -893,7 +899,13 @@ select_kqueue_fromfd(PyTypeObject *type, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:fromfd", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = select_kqueue_fromfd_impl(type, fd);
|
||||
|
@ -1047,4 +1059,4 @@ exit:
|
|||
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
|
||||
#define SELECT_KQUEUE_CONTROL_METHODDEF
|
||||
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
|
||||
/*[clinic end generated code: output=04c4019eb5a4d464 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=122a49f131cdd9d9 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -23,7 +23,13 @@ signal_alarm(PyObject *module, PyObject *arg)
|
|||
int seconds;
|
||||
long _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:alarm", &seconds)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
seconds = _PyLong_AsInt(arg);
|
||||
if (seconds == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = signal_alarm_impl(module, seconds);
|
||||
|
@ -120,7 +126,13 @@ signal_getsignal(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int signalnum;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:getsignal", &signalnum)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
signalnum = _PyLong_AsInt(arg);
|
||||
if (signalnum == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = signal_getsignal_impl(module, signalnum);
|
||||
|
@ -150,7 +162,13 @@ signal_strsignal(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int signalnum;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:strsignal", &signalnum)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
signalnum = _PyLong_AsInt(arg);
|
||||
if (signalnum == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = signal_strsignal_impl(module, signalnum);
|
||||
|
@ -255,7 +273,13 @@ signal_getitimer(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int which;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:getitimer", &which)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
which = _PyLong_AsInt(arg);
|
||||
if (which == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = signal_getitimer_impl(module, which);
|
||||
|
@ -348,7 +372,7 @@ signal_sigwait(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
sigset_t sigset;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:sigwait", _Py_Sigset_Converter, &sigset)) {
|
||||
if (!_Py_Sigset_Converter(arg, &sigset)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = signal_sigwait_impl(module, sigset);
|
||||
|
@ -406,7 +430,7 @@ signal_sigwaitinfo(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
sigset_t sigset;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:sigwaitinfo", _Py_Sigset_Converter, &sigset)) {
|
||||
if (!_Py_Sigset_Converter(arg, &sigset)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = signal_sigwaitinfo_impl(module, sigset);
|
||||
|
@ -534,4 +558,4 @@ exit:
|
|||
#ifndef SIGNAL_PTHREAD_KILL_METHODDEF
|
||||
#define SIGNAL_PTHREAD_KILL_METHODDEF
|
||||
#endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */
|
||||
/*[clinic end generated code: output=fa0040750f4c1fcb input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=4ed8c36860f9f577 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -24,9 +24,14 @@ spwd_getspnam(PyObject *module, PyObject *arg_)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *arg;
|
||||
|
||||
if (!PyArg_Parse(arg_, "U:getspnam", &arg)) {
|
||||
if (!PyUnicode_Check(arg_)) {
|
||||
_PyArg_BadArgument("getspnam", "str", arg_);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg_) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
arg = arg_;
|
||||
return_value = spwd_getspnam_impl(module, arg);
|
||||
|
||||
exit:
|
||||
|
@ -66,4 +71,4 @@ spwd_getspall(PyObject *module, PyObject *Py_UNUSED(ignored))
|
|||
#ifndef SPWD_GETSPALL_METHODDEF
|
||||
#define SPWD_GETSPALL_METHODDEF
|
||||
#endif /* !defined(SPWD_GETSPALL_METHODDEF) */
|
||||
/*[clinic end generated code: output=07cd8af0afd77fe7 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=44a7c196d4b48f4e input=a9049054013a1b77]*/
|
||||
|
|
|
@ -121,9 +121,18 @@ unicodedata_UCD_category(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int chr;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:category", &chr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("category", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("category", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
chr = PyUnicode_READ_CHAR(arg, 0);
|
||||
return_value = unicodedata_UCD_category_impl(self, chr);
|
||||
|
||||
exit:
|
||||
|
@ -150,9 +159,18 @@ unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int chr;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:bidirectional", &chr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("bidirectional", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("bidirectional", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
chr = PyUnicode_READ_CHAR(arg, 0);
|
||||
return_value = unicodedata_UCD_bidirectional_impl(self, chr);
|
||||
|
||||
exit:
|
||||
|
@ -180,9 +198,18 @@ unicodedata_UCD_combining(PyObject *self, PyObject *arg)
|
|||
int chr;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:combining", &chr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("combining", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("combining", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
chr = PyUnicode_READ_CHAR(arg, 0);
|
||||
_return_value = unicodedata_UCD_combining_impl(self, chr);
|
||||
if ((_return_value == -1) && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
|
@ -215,9 +242,18 @@ unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
|
|||
int chr;
|
||||
int _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:mirrored", &chr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("mirrored", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("mirrored", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
chr = PyUnicode_READ_CHAR(arg, 0);
|
||||
_return_value = unicodedata_UCD_mirrored_impl(self, chr);
|
||||
if ((_return_value == -1) && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
|
@ -246,9 +282,18 @@ unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int chr;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("east_asian_width", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("east_asian_width", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
chr = PyUnicode_READ_CHAR(arg, 0);
|
||||
return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
|
||||
|
||||
exit:
|
||||
|
@ -275,9 +320,18 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int chr;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:decomposition", &chr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("decomposition", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("decomposition", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
chr = PyUnicode_READ_CHAR(arg, 0);
|
||||
return_value = unicodedata_UCD_decomposition_impl(self, chr);
|
||||
|
||||
exit:
|
||||
|
@ -411,4 +465,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=67f474927be668bf input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=709241b99d010896 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -215,7 +215,11 @@ zlib_Compress_compress(compobject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer data = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:compress", &data)) {
|
||||
if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&data, 'C')) {
|
||||
_PyArg_BadArgument("compress", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = zlib_Compress_compress_impl(self, &data);
|
||||
|
@ -553,4 +557,4 @@ exit:
|
|||
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
|
||||
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
|
||||
#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
|
||||
/*[clinic end generated code: output=e721c15e7af2d2fd input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=bea1e3c64573d9fd input=a9049054013a1b77]*/
|
||||
|
|
|
@ -354,7 +354,7 @@ bytearray_append(PyByteArrayObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int item;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:append", _getbytevalue, &item)) {
|
||||
if (!_getbytevalue(arg, &item)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytearray_append_impl(self, item);
|
||||
|
@ -430,7 +430,7 @@ bytearray_remove(PyByteArrayObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int value;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:remove", _getbytevalue, &value)) {
|
||||
if (!_getbytevalue(arg, &value)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytearray_remove_impl(self, value);
|
||||
|
@ -640,9 +640,14 @@ bytearray_fromhex(PyTypeObject *type, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *string;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:fromhex", &string)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("fromhex", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
string = arg;
|
||||
return_value = bytearray_fromhex_impl(type, string);
|
||||
|
||||
exit:
|
||||
|
@ -712,4 +717,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return bytearray_sizeof_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=b88bb192dddca6e1 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=cd3e13a1905a473c input=a9049054013a1b77]*/
|
||||
|
|
|
@ -66,7 +66,11 @@ bytes_partition(PyBytesObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer sep = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:partition", &sep)) {
|
||||
if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&sep, 'C')) {
|
||||
_PyArg_BadArgument("partition", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytes_partition_impl(self, &sep);
|
||||
|
@ -105,7 +109,11 @@ bytes_rpartition(PyBytesObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer sep = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:rpartition", &sep)) {
|
||||
if (PyObject_GetBuffer(arg, &sep, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&sep, 'C')) {
|
||||
_PyArg_BadArgument("rpartition", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytes_rpartition_impl(self, &sep);
|
||||
|
@ -491,12 +499,17 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *string;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:fromhex", &string)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("fromhex", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
string = arg;
|
||||
return_value = bytes_fromhex_impl(type, string);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=07b33ac65362301b input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=dc9aa04f0007ab11 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -228,7 +228,17 @@ float___getformat__(PyTypeObject *type, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
const char *typestr;
|
||||
|
||||
if (!PyArg_Parse(arg, "s:__getformat__", &typestr)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("__getformat__", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t typestr_length;
|
||||
typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length);
|
||||
if (typestr == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(typestr) != (size_t)typestr_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = float___getformat___impl(type, typestr);
|
||||
|
@ -297,12 +307,17 @@ float___format__(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *format_spec;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("__format__", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
format_spec = arg;
|
||||
return_value = float___format___impl(self, format_spec);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=091dd499f5386a6c input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/
|
||||
|
|
|
@ -58,9 +58,14 @@ int___format__(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *format_spec;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("__format__", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
format_spec = arg;
|
||||
return_value = int___format___impl(self, format_spec);
|
||||
|
||||
exit:
|
||||
|
@ -239,4 +244,4 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=403ccd096555fd1e input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=7436b5f4decdcf9d input=a9049054013a1b77]*/
|
||||
|
|
|
@ -166,7 +166,13 @@ object___reduce_ex__(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int protocol;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:__reduce_ex__", &protocol)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
protocol = _PyLong_AsInt(arg);
|
||||
if (protocol == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = object___reduce_ex___impl(self, protocol);
|
||||
|
@ -193,9 +199,14 @@ object___format__(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *format_spec;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("__format__", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
format_spec = arg;
|
||||
return_value = object___format___impl(self, format_spec);
|
||||
|
||||
exit:
|
||||
|
@ -237,4 +248,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return object___dir___impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=8c4c856859564eaa input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=09f3453839e60136 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -898,9 +898,23 @@ unicode_zfill(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_ssize_t width;
|
||||
|
||||
if (!PyArg_Parse(arg, "n:zfill", &width)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(arg);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
width = ival;
|
||||
}
|
||||
return_value = unicode_zfill_impl(self, width);
|
||||
|
||||
exit:
|
||||
|
@ -925,9 +939,14 @@ unicode___format__(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *format_spec;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("__format__", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
format_spec = arg;
|
||||
return_value = unicode___format___impl(self, format_spec);
|
||||
|
||||
exit:
|
||||
|
@ -951,4 +970,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return unicode_sizeof_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=d323802b67bfc6d8 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=ff6acd5abd1998eb input=a9049054013a1b77]*/
|
||||
|
|
|
@ -147,12 +147,26 @@ stringlib_zfill(PyObject *self, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_ssize_t width;
|
||||
|
||||
if (!PyArg_Parse(arg, "n:zfill", &width)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = PyNumber_Index(arg);
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
width = ival;
|
||||
}
|
||||
return_value = stringlib_zfill_impl(self, width);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=d09ba158d470566e input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=bf2ef501639e1190 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -158,7 +158,13 @@ msvcrt_get_osfhandle(PyObject *module, PyObject *arg)
|
|||
int fd;
|
||||
void *_return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
fd = _PyLong_AsInt(arg);
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = msvcrt_get_osfhandle_impl(module, fd);
|
||||
|
@ -319,7 +325,14 @@ msvcrt_putch(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
char char_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "c:putch", &char_value)) {
|
||||
if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
|
||||
char_value = PyBytes_AS_STRING(arg)[0];
|
||||
}
|
||||
else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
|
||||
char_value = PyByteArray_AS_STRING(arg)[0];
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("putch", "a byte string of length 1", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = msvcrt_putch_impl(module, char_value);
|
||||
|
@ -346,9 +359,18 @@ msvcrt_putwch(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int unicode_char;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("putwch", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("putwch", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
unicode_char = PyUnicode_READ_CHAR(arg, 0);
|
||||
return_value = msvcrt_putwch_impl(module, unicode_char);
|
||||
|
||||
exit:
|
||||
|
@ -377,7 +399,14 @@ msvcrt_ungetch(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
char char_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
|
||||
if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) {
|
||||
char_value = PyBytes_AS_STRING(arg)[0];
|
||||
}
|
||||
else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) {
|
||||
char_value = PyByteArray_AS_STRING(arg)[0];
|
||||
}
|
||||
else {
|
||||
_PyArg_BadArgument("ungetch", "a byte string of length 1", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = msvcrt_ungetch_impl(module, char_value);
|
||||
|
@ -404,9 +433,18 @@ msvcrt_ungetwch(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int unicode_char;
|
||||
|
||||
if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("ungetwch", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg)) {
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_GET_LENGTH(arg) != 1) {
|
||||
_PyArg_BadArgument("ungetwch", "a unicode character", arg);
|
||||
goto exit;
|
||||
}
|
||||
unicode_char = PyUnicode_READ_CHAR(arg, 0);
|
||||
return_value = msvcrt_ungetwch_impl(module, unicode_char);
|
||||
|
||||
exit:
|
||||
|
@ -516,7 +554,13 @@ msvcrt_set_error_mode(PyObject *module, PyObject *arg)
|
|||
int mode;
|
||||
long _return_value;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
mode = _PyLong_AsInt(arg);
|
||||
if (mode == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
_return_value = msvcrt_set_error_mode_impl(module, mode);
|
||||
|
@ -549,7 +593,13 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
unsigned int mode;
|
||||
|
||||
if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
mode = (unsigned int)PyLong_AsUnsignedLongMask(arg);
|
||||
if (mode == (unsigned int)-1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = msvcrt_SetErrorMode_impl(module, mode);
|
||||
|
@ -569,4 +619,4 @@ exit:
|
|||
#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
|
||||
#define MSVCRT_SET_ERROR_MODE_METHODDEF
|
||||
#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
|
||||
/*[clinic end generated code: output=632089ff9236ac77 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=2530b4ff248563b4 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -541,7 +541,7 @@ winreg_FlushKey(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
HKEY key;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:FlushKey", clinic_HKEY_converter, &key)) {
|
||||
if (!clinic_HKEY_converter(arg, &key)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = winreg_FlushKey_impl(module, key);
|
||||
|
@ -734,7 +734,7 @@ winreg_QueryInfoKey(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
HKEY key;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:QueryInfoKey", clinic_HKEY_converter, &key)) {
|
||||
if (!clinic_HKEY_converter(arg, &key)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = winreg_QueryInfoKey_impl(module, key);
|
||||
|
@ -1021,7 +1021,7 @@ winreg_DisableReflectionKey(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
HKEY key;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:DisableReflectionKey", clinic_HKEY_converter, &key)) {
|
||||
if (!clinic_HKEY_converter(arg, &key)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = winreg_DisableReflectionKey_impl(module, key);
|
||||
|
@ -1055,7 +1055,7 @@ winreg_EnableReflectionKey(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
HKEY key;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:EnableReflectionKey", clinic_HKEY_converter, &key)) {
|
||||
if (!clinic_HKEY_converter(arg, &key)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = winreg_EnableReflectionKey_impl(module, key);
|
||||
|
@ -1087,7 +1087,7 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
HKEY key;
|
||||
|
||||
if (!PyArg_Parse(arg, "O&:QueryReflectionKey", clinic_HKEY_converter, &key)) {
|
||||
if (!clinic_HKEY_converter(arg, &key)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = winreg_QueryReflectionKey_impl(module, key);
|
||||
|
@ -1095,4 +1095,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=ff2cc1951ab1a56c input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=82bd56c524c6c3dd input=a9049054013a1b77]*/
|
||||
|
|
|
@ -122,7 +122,13 @@ builtin_chr(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
int i;
|
||||
|
||||
if (!PyArg_Parse(arg, "i:chr", &i)) {
|
||||
if (PyFloat_Check(arg)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"integer argument expected, got float" );
|
||||
goto exit;
|
||||
}
|
||||
i = _PyLong_AsInt(arg);
|
||||
if (i == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = builtin_chr_impl(module, i);
|
||||
|
@ -711,4 +717,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=fa8d97ac8695363b input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -143,9 +143,14 @@ _imp_init_frozen(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("init_frozen", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_init_frozen_impl(module, name);
|
||||
|
||||
exit:
|
||||
|
@ -170,9 +175,14 @@ _imp_get_frozen_object(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("get_frozen_object", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_get_frozen_object_impl(module, name);
|
||||
|
||||
exit:
|
||||
|
@ -197,9 +207,14 @@ _imp_is_frozen_package(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("is_frozen_package", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_is_frozen_package_impl(module, name);
|
||||
|
||||
exit:
|
||||
|
@ -224,9 +239,14 @@ _imp_is_builtin(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("is_builtin", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_is_builtin_impl(module, name);
|
||||
|
||||
exit:
|
||||
|
@ -251,9 +271,14 @@ _imp_is_frozen(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *name;
|
||||
|
||||
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
|
||||
if (!PyUnicode_Check(arg)) {
|
||||
_PyArg_BadArgument("is_frozen", "str", arg);
|
||||
goto exit;
|
||||
}
|
||||
if (PyUnicode_READY(arg) == -1) {
|
||||
goto exit;
|
||||
}
|
||||
name = arg;
|
||||
return_value = _imp_is_frozen_impl(module, name);
|
||||
|
||||
exit:
|
||||
|
@ -396,4 +421,4 @@ exit:
|
|||
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
|
||||
#define _IMP_EXEC_DYNAMIC_METHODDEF
|
||||
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
|
||||
/*[clinic end generated code: output=ad747b76e105fff2 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=d8be58c9541122f1 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -121,7 +121,11 @@ marshal_loads(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
Py_buffer bytes = {NULL, NULL};
|
||||
|
||||
if (!PyArg_Parse(arg, "y*:loads", &bytes)) {
|
||||
if (PyObject_GetBuffer(arg, &bytes, PyBUF_SIMPLE) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (!PyBuffer_IsContiguous(&bytes, 'C')) {
|
||||
_PyArg_BadArgument("loads", "contiguous buffer", arg);
|
||||
goto exit;
|
||||
}
|
||||
return_value = marshal_loads_impl(module, &bytes);
|
||||
|
@ -134,4 +138,4 @@ exit:
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=cbb6128201bee7e0 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=8262e7e6c8cbc1ef input=a9049054013a1b77]*/
|
||||
|
|
|
@ -612,6 +612,14 @@ convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
|
||||
/* Format an error message generated by convertsimple(). */
|
||||
|
||||
void
|
||||
_PyArg_BadArgument(const char *fname, const char *expected, PyObject *arg)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "%.200s() argument must be %.50s, not %.50s",
|
||||
fname, expected,
|
||||
arg == Py_None ? "None" : arg->ob_type->tp_name);
|
||||
}
|
||||
|
||||
static const char *
|
||||
converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
|
||||
{
|
||||
|
|
|
@ -807,11 +807,10 @@ class CLanguage(Language):
|
|||
{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
|
||||
|
@ -2346,7 +2345,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
|
||||
# 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:
|
||||
|
@ -2383,8 +2382,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
|
||||
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
|
||||
|
@ -2399,8 +2397,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
|
||||
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()
|
||||
|
@ -2449,7 +2446,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
"""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,
|
||||
|
@ -2465,8 +2462,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
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:
|
||||
|
@ -2487,7 +2483,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
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):
|
||||
|
@ -2540,6 +2536,52 @@ class CConverter(metaclass=CConverterAutoRegister):
|
|||
"""
|
||||
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'
|
||||
|
@ -2556,6 +2598,28 @@ class bool_converter(CConverter):
|
|||
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)
|
||||
|
@ -2571,6 +2635,22 @@ class char_converter(CConverter):
|
|||
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):
|
||||
|
@ -2583,6 +2663,53 @@ 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):
|
||||
|
@ -2591,6 +2718,36 @@ 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
|
||||
|
@ -2617,6 +2774,36 @@ class int_converter(CConverter):
|
|||
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
|
||||
|
@ -2628,12 +2815,42 @@ class unsigned_int_converter(CConverter):
|
|||
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
|
||||
|
@ -2645,12 +2862,38 @@ class unsigned_long_converter(CConverter):
|
|||
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
|
||||
|
@ -2662,6 +2905,17 @@ class unsigned_long_long_converter(CConverter):
|
|||
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"
|
||||
|
@ -2675,6 +2929,29 @@ class Py_ssize_t_converter(CConverter):
|
|||
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'
|
||||
|
@ -2692,6 +2969,16 @@ class size_t_converter(CConverter):
|
|||
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'
|
||||
|
@ -2699,12 +2986,32 @@ class float_converter(CConverter):
|
|||
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'
|
||||
|
@ -2712,6 +3019,16 @@ class Py_complex_converter(CConverter):
|
|||
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 *'
|
||||
|
@ -2773,9 +3090,28 @@ class str_converter(CConverter):
|
|||
|
||||
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
|
||||
|
@ -2829,16 +3165,52 @@ class PyBytesObject_converter(CConverter):
|
|||
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)
|
||||
|
@ -2883,9 +3255,54 @@ class Py_buffer_converter(CConverter):
|
|||
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):
|
||||
|
|
Loading…
Reference in New Issue