GeezerVison is showing github.com — bpo-23867: Argument Clinic: inline parsing code for a single position… · python/cpython@32d96a2
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Include/modsupport.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,6 +66,8 @@ PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); | 66 | 66 | #define _PyArg_NoPositional(funcname, args) \ | 67 | 67 | ((args) == NULL || _PyArg_NoPositional((funcname), (args))) | 68 | 68 |
| | 69 | +PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, PyObject *); | | 70 | + | 69 | 71 | #endif | 70 | 72 |
| 71 | 73 | PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); | |
Collapse file Copy file name to clipboardExpand all lines: Lib/test/clinic.test +18-8Lines changed: 18 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -201,9 +201,11 @@ test_PyBytesObject_converter(PyObject *module, PyObject *arg) | 201 | 201 | PyObject *return_value = NULL; | 202 | 202 | PyBytesObject *a; | 203 | 203 |
| 204 | | - if (!PyArg_Parse(arg, "S:test_PyBytesObject_converter", &a)) { | | 204 | + if (!PyBytes_Check(arg)) { | | 205 | + _PyArg_BadArgument("test_PyBytesObject_converter", "bytes", arg); | 205 | 206 | goto exit; | 206 | 207 | } | | 208 | + a = (PyBytesObject *)arg; | 207 | 209 | return_value = test_PyBytesObject_converter_impl(module, a); | 208 | 210 |
| 209 | 211 | exit: | @@ -212,7 +214,7 @@ exit: | 212 | 214 |
| 213 | 215 | static PyObject * | 214 | 216 | test_PyBytesObject_converter_impl(PyObject *module, PyBytesObject *a) | 215 | | -/*[clinic end generated code: output=8dbf43c604ced031 input=12b10c7cb5750400]*/ | | 217 | +/*[clinic end generated code: output=fd69d6df4d26c853 input=12b10c7cb5750400]*/ | 216 | 218 |
| 217 | 219 | /*[clinic input] | 218 | 220 | test_PyByteArrayObject_converter | @@ -239,9 +241,11 @@ test_PyByteArrayObject_converter(PyObject *module, PyObject *arg) | 239 | 241 | PyObject *return_value = NULL; | 240 | 242 | PyByteArrayObject *a; | 241 | 243 |
| 242 | | - if (!PyArg_Parse(arg, "Y:test_PyByteArrayObject_converter", &a)) { | | 244 | + if (!PyByteArray_Check(arg)) { | | 245 | + _PyArg_BadArgument("test_PyByteArrayObject_converter", "bytearray", arg); | 243 | 246 | goto exit; | 244 | 247 | } | | 248 | + a = (PyByteArrayObject *)arg; | 245 | 249 | return_value = test_PyByteArrayObject_converter_impl(module, a); | 246 | 250 |
| 247 | 251 | exit: | @@ -250,7 +254,7 @@ exit: | 250 | 254 |
| 251 | 255 | static PyObject * | 252 | 256 | test_PyByteArrayObject_converter_impl(PyObject *module, PyByteArrayObject *a) | 253 | | -/*[clinic end generated code: output=ade99fc6705e7d6e input=5a657da535d194ae]*/ | | 257 | +/*[clinic end generated code: output=d309c909182c4183 input=5a657da535d194ae]*/ | 254 | 258 |
| 255 | 259 | /*[clinic input] | 256 | 260 | test_unicode_converter | @@ -277,9 +281,14 @@ test_unicode_converter(PyObject *module, PyObject *arg) | 277 | 281 | PyObject *return_value = NULL; | 278 | 282 | PyObject *a; | 279 | 283 |
| 280 | | - if (!PyArg_Parse(arg, "U:test_unicode_converter", &a)) { | | 284 | + if (!PyUnicode_Check(arg)) { | | 285 | + _PyArg_BadArgument("test_unicode_converter", "str", arg); | 281 | 286 | goto exit; | 282 | 287 | } | | 288 | + if (PyUnicode_READY(arg) == -1) { | | 289 | + goto exit; | | 290 | + } | | 291 | + a = arg; | 283 | 292 | return_value = test_unicode_converter_impl(module, a); | 284 | 293 |
| 285 | 294 | exit: | @@ -288,7 +297,7 @@ exit: | 288 | 297 |
| 289 | 298 | static PyObject * | 290 | 299 | test_unicode_converter_impl(PyObject *module, PyObject *a) | 291 | | -/*[clinic end generated code: output=504a2c8d00370adf input=aa33612df92aa9c5]*/ | | 300 | +/*[clinic end generated code: output=ca603454e1f8f764 input=aa33612df92aa9c5]*/ | 292 | 301 |
| 293 | 302 | /*[clinic input] | 294 | 303 | test_bool_converter | @@ -1027,7 +1036,8 @@ test_Py_complex_converter(PyObject *module, PyObject *arg) | 1027 | 1036 | PyObject *return_value = NULL; | 1028 | 1037 | Py_complex a; | 1029 | 1038 |
| 1030 | | - if (!PyArg_Parse(arg, "D:test_Py_complex_converter", &a)) { | | 1039 | + a = PyComplex_AsCComplex(arg); | | 1040 | + if (PyErr_Occurred()) { | 1031 | 1041 | goto exit; | 1032 | 1042 | } | 1033 | 1043 | return_value = test_Py_complex_converter_impl(module, a); | @@ -1038,7 +1048,7 @@ exit: | 1038 | 1048 |
| 1039 | 1049 | static PyObject * | 1040 | 1050 | test_Py_complex_converter_impl(PyObject *module, Py_complex a) | 1041 | | -/*[clinic end generated code: output=27efb4ff772d6170 input=070f216a515beb79]*/ | | 1051 | +/*[clinic end generated code: output=c2ecbec2144ca540 input=070f216a515beb79]*/ | 1042 | 1052 |
| 1043 | 1053 | /*[clinic input] | 1044 | 1054 | test_str_converter | |
Collapse file Copy file name to clipboardExpand all lines: Modules/_io/clinic/bufferedio.c.h +34-6Lines changed: 34 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,13 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg) | 19 | 19 | PyObject *return_value = NULL; | 20 | 20 | Py_buffer buffer = {NULL, NULL}; | 21 | 21 |
| 22 | | - if (!PyArg_Parse(arg, "w*:readinto", &buffer)) { | | 22 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 23 | + PyErr_Clear(); | | 24 | + _PyArg_BadArgument("readinto", "read-write bytes-like object", arg); | | 25 | + goto exit; | | 26 | + } | | 27 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 28 | + _PyArg_BadArgument("readinto", "contiguous buffer", arg); | 23 | 29 | goto exit; | 24 | 30 | } | 25 | 31 | return_value = _io__BufferedIOBase_readinto_impl(self, &buffer); | @@ -50,7 +56,13 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg) | 50 | 56 | PyObject *return_value = NULL; | 51 | 57 | Py_buffer buffer = {NULL, NULL}; | 52 | 58 |
| 53 | | - if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) { | | 59 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 60 | + PyErr_Clear(); | | 61 | + _PyArg_BadArgument("readinto1", "read-write bytes-like object", arg); | | 62 | + goto exit; | | 63 | + } | | 64 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 65 | + _PyArg_BadArgument("readinto1", "contiguous buffer", arg); | 54 | 66 | goto exit; | 55 | 67 | } | 56 | 68 | return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer); | @@ -183,7 +195,13 @@ _io__Buffered_readinto(buffered *self, PyObject *arg) | 183 | 195 | PyObject *return_value = NULL; | 184 | 196 | Py_buffer buffer = {NULL, NULL}; | 185 | 197 |
| 186 | | - if (!PyArg_Parse(arg, "w*:readinto", &buffer)) { | | 198 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 199 | + PyErr_Clear(); | | 200 | + _PyArg_BadArgument("readinto", "read-write bytes-like object", arg); | | 201 | + goto exit; | | 202 | + } | | 203 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 204 | + _PyArg_BadArgument("readinto", "contiguous buffer", arg); | 187 | 205 | goto exit; | 188 | 206 | } | 189 | 207 | return_value = _io__Buffered_readinto_impl(self, &buffer); | @@ -214,7 +232,13 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg) | 214 | 232 | PyObject *return_value = NULL; | 215 | 233 | Py_buffer buffer = {NULL, NULL}; | 216 | 234 |
| 217 | | - if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) { | | 235 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 236 | + PyErr_Clear(); | | 237 | + _PyArg_BadArgument("readinto1", "read-write bytes-like object", arg); | | 238 | + goto exit; | | 239 | + } | | 240 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 241 | + _PyArg_BadArgument("readinto1", "contiguous buffer", arg); | 218 | 242 | goto exit; | 219 | 243 | } | 220 | 244 | return_value = _io__Buffered_readinto1_impl(self, &buffer); | @@ -390,7 +414,11 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg) | 390 | 414 | PyObject *return_value = NULL; | 391 | 415 | Py_buffer buffer = {NULL, NULL}; | 392 | 416 |
| 393 | | - if (!PyArg_Parse(arg, "y*:write", &buffer)) { | | 417 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) { | | 418 | + goto exit; | | 419 | + } | | 420 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 421 | + _PyArg_BadArgument("write", "contiguous buffer", arg); | 394 | 422 | goto exit; | 395 | 423 | } | 396 | 424 | return_value = _io_BufferedWriter_write_impl(self, &buffer); | @@ -476,4 +504,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) | 476 | 504 | exit: | 477 | 505 | return return_value; | 478 | 506 | } | 479 | | -/*[clinic end generated code: output=cb4bf8d50533953b input=a9049054013a1b77]*/ | | 507 | +/*[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]*/ |
Collapse file Copy file name to clipboardExpand all lines: Modules/_io/clinic/bytesio.c.h +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -296,7 +296,13 @@ _io_BytesIO_readinto(bytesio *self, PyObject *arg) | 296 | 296 | PyObject *return_value = NULL; | 297 | 297 | Py_buffer buffer = {NULL, NULL}; | 298 | 298 |
| 299 | | - if (!PyArg_Parse(arg, "w*:readinto", &buffer)) { | | 299 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 300 | + PyErr_Clear(); | | 301 | + _PyArg_BadArgument("readinto", "read-write bytes-like object", arg); | | 302 | + goto exit; | | 303 | + } | | 304 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 305 | + _PyArg_BadArgument("readinto", "contiguous buffer", arg); | 300 | 306 | goto exit; | 301 | 307 | } | 302 | 308 | return_value = _io_BytesIO_readinto_impl(self, &buffer); | @@ -444,4 +450,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) | 444 | 450 | exit: | 445 | 451 | return return_value; | 446 | 452 | } | 447 | | -/*[clinic end generated code: output=89538a941ae1267a input=a9049054013a1b77]*/ | | 453 | +/*[clinic end generated code: output=f6e720f38fc6e3cd input=a9049054013a1b77]*/ |
Collapse file Copy file name to clipboardExpand all lines: Modules/_io/clinic/fileio.c.h +13-3Lines changed: 13 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,7 +156,13 @@ _io_FileIO_readinto(fileio *self, PyObject *arg) | 156 | 156 | PyObject *return_value = NULL; | 157 | 157 | Py_buffer buffer = {NULL, NULL}; | 158 | 158 |
| 159 | | - if (!PyArg_Parse(arg, "w*:readinto", &buffer)) { | | 159 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 160 | + PyErr_Clear(); | | 161 | + _PyArg_BadArgument("readinto", "read-write bytes-like object", arg); | | 162 | + goto exit; | | 163 | + } | | 164 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 165 | + _PyArg_BadArgument("readinto", "contiguous buffer", arg); | 160 | 166 | goto exit; | 161 | 167 | } | 162 | 168 | return_value = _io_FileIO_readinto_impl(self, &buffer); | @@ -245,7 +251,11 @@ _io_FileIO_write(fileio *self, PyObject *arg) | 245 | 251 | PyObject *return_value = NULL; | 246 | 252 | Py_buffer b = {NULL, NULL}; | 247 | 253 |
| 248 | | - if (!PyArg_Parse(arg, "y*:write", &b)) { | | 254 | + if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { | | 255 | + goto exit; | | 256 | + } | | 257 | + if (!PyBuffer_IsContiguous(&b, 'C')) { | | 258 | + _PyArg_BadArgument("write", "contiguous buffer", arg); | 249 | 259 | goto exit; | 250 | 260 | } | 251 | 261 | return_value = _io_FileIO_write_impl(self, &b); | @@ -373,4 +383,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored)) | 373 | 383 | #ifndef _IO_FILEIO_TRUNCATE_METHODDEF | 374 | 384 | #define _IO_FILEIO_TRUNCATE_METHODDEF | 375 | 385 | #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ | 376 | | -/*[clinic end generated code: output=9d44e7035bce105d input=a9049054013a1b77]*/ | | 386 | +/*[clinic end generated code: output=8be0ea9a5ac7aa43 input=a9049054013a1b77]*/ |
Collapse file Copy file name to clipboardExpand all lines: Modules/_io/clinic/textio.c.h +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -250,9 +250,14 @@ _io_TextIOWrapper_write(textio *self, PyObject *arg) | 250 | 250 | PyObject *return_value = NULL; | 251 | 251 | PyObject *text; | 252 | 252 |
| 253 | | - if (!PyArg_Parse(arg, "U:write", &text)) { | | 253 | + if (!PyUnicode_Check(arg)) { | | 254 | + _PyArg_BadArgument("write", "str", arg); | 254 | 255 | goto exit; | 255 | 256 | } | | 257 | + if (PyUnicode_READY(arg) == -1) { | | 258 | + goto exit; | | 259 | + } | | 260 | + text = arg; | 256 | 261 | return_value = _io_TextIOWrapper_write_impl(self, text); | 257 | 262 |
| 258 | 263 | exit: | @@ -504,4 +509,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) | 504 | 509 | { | 505 | 510 | return _io_TextIOWrapper_close_impl(self); | 506 | 511 | } | 507 | | -/*[clinic end generated code: output=a811badd76bfe92e input=a9049054013a1b77]*/ | | 512 | +/*[clinic end generated code: output=b933f08c2f2d85cd input=a9049054013a1b77]*/ |
Collapse file Copy file name to clipboardExpand all lines: Modules/_io/clinic/winconsoleio.c.h +13-3Lines changed: 13 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,7 +156,13 @@ _io__WindowsConsoleIO_readinto(winconsoleio *self, PyObject *arg) | 156 | 156 | PyObject *return_value = NULL; | 157 | 157 | Py_buffer buffer = {NULL, NULL}; | 158 | 158 |
| 159 | | - if (!PyArg_Parse(arg, "w*:readinto", &buffer)) { | | 159 | + if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) { | | 160 | + PyErr_Clear(); | | 161 | + _PyArg_BadArgument("readinto", "read-write bytes-like object", arg); | | 162 | + goto exit; | | 163 | + } | | 164 | + if (!PyBuffer_IsContiguous(&buffer, 'C')) { | | 165 | + _PyArg_BadArgument("readinto", "contiguous buffer", arg); | 160 | 166 | goto exit; | 161 | 167 | } | 162 | 168 | return_value = _io__WindowsConsoleIO_readinto_impl(self, &buffer); | @@ -255,7 +261,11 @@ _io__WindowsConsoleIO_write(winconsoleio *self, PyObject *arg) | 255 | 261 | PyObject *return_value = NULL; | 256 | 262 | Py_buffer b = {NULL, NULL}; | 257 | 263 |
| 258 | | - if (!PyArg_Parse(arg, "y*:write", &b)) { | | 264 | + if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) { | | 265 | + goto exit; | | 266 | + } | | 267 | + if (!PyBuffer_IsContiguous(&b, 'C')) { | | 268 | + _PyArg_BadArgument("write", "contiguous buffer", arg); | 259 | 269 | goto exit; | 260 | 270 | } | 261 | 271 | return_value = _io__WindowsConsoleIO_write_impl(self, &b); | @@ -328,4 +338,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored)) | 328 | 338 | #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF | 329 | 339 | #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF | 330 | 340 | #endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */ | 331 | | -/*[clinic end generated code: output=080af41338394b49 input=a9049054013a1b77]*/ | | 341 | +/*[clinic end generated code: output=4337e8de65915a1e input=a9049054013a1b77]*/ |
Collapse file Copy file name to clipboardExpand all lines: Modules/_sha3/clinic/sha3module.c.h +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -83,7 +83,7 @@ _sha3_shake_128_digest(SHA3object *self, PyObject *arg) | 83 | 83 | PyObject *return_value = NULL; | 84 | 84 | unsigned long length; | 85 | 85 |
| 86 | | - if (!PyArg_Parse(arg, "O&:digest", _PyLong_UnsignedLong_Converter, &length)) { | | 86 | + if (!_PyLong_UnsignedLong_Converter(arg, &length)) { | 87 | 87 | goto exit; | 88 | 88 | } | 89 | 89 | return_value = _sha3_shake_128_digest_impl(self, length); | @@ -110,12 +110,12 @@ _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg) | 110 | 110 | PyObject *return_value = NULL; | 111 | 111 | unsigned long length; | 112 | 112 |
| 113 | | - if (!PyArg_Parse(arg, "O&:hexdigest", _PyLong_UnsignedLong_Converter, &length)) { | | 113 | + if (!_PyLong_UnsignedLong_Converter(arg, &length)) { | 114 | 114 | goto exit; | 115 | 115 | } | 116 | 116 | return_value = _sha3_shake_128_hexdigest_impl(self, length); | 117 | 117 |
| 118 | 118 | exit: | 119 | 119 | return return_value; | 120 | 120 | } | 121 | | -/*[clinic end generated code: output=bf823532a7bffe68 input=a9049054013a1b77]*/ | | 121 | +/*[clinic end generated code: output=5b3e99b9a96471e8 input=a9049054013a1b77]*/ |
Collapse file Copy file name to clipboardExpand all lines: Modules/_struct.c +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -96,7 +96,7 @@ class cache_struct_converter(CConverter): | 96 | 96 | [python start generated code]*/ | 97 | 97 | /*[python end generated code: output=da39a3ee5e6b4b0d input=49957cca130ffb63]*/ | 98 | 98 |
| 99 | | -static int cache_struct_converter(PyObject *, PyObject **); | | 99 | +static int cache_struct_converter(PyObject *, PyStructObject **); | 100 | 100 |
| 101 | 101 | #include "clinic/_struct.c.h" | 102 | 102 |
| @@ -2072,7 +2072,7 @@ PyTypeObject PyStructType = { | 2072 | 2072 | static PyObject *cache = NULL; | 2073 | 2073 |
| 2074 | 2074 | static int | 2075 | | -cache_struct_converter(PyObject *fmt, PyObject **ptr) | | 2075 | +cache_struct_converter(PyObject *fmt, PyStructObject **ptr) | 2076 | 2076 | { | 2077 | 2077 | PyObject * s_object; | 2078 | 2078 |
| @@ -2091,7 +2091,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr) | 2091 | 2091 | s_object = PyDict_GetItem(cache, fmt); | 2092 | 2092 | if (s_object != NULL) { | 2093 | 2093 | Py_INCREF(s_object); | 2094 | | - *ptr = s_object; | | 2094 | + *ptr = (PyStructObject *)s_object; | 2095 | 2095 | return Py_CLEANUP_SUPPORTED; | 2096 | 2096 | } | 2097 | 2097 |
| @@ -2102,7 +2102,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr) | 2102 | 2102 | /* Attempt to cache the result */ | 2103 | 2103 | if (PyDict_SetItem(cache, fmt, s_object) == -1) | 2104 | 2104 | PyErr_Clear(); | 2105 | | - *ptr = s_object; | | 2105 | + *ptr = (PyStructObject *)s_object; | 2106 | 2106 | return Py_CLEANUP_SUPPORTED; | 2107 | 2107 | } | 2108 | 2108 | return 0; | @@ -2157,7 +2157,7 @@ pack(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | 2157 | 2157 | } | 2158 | 2158 | format = args[0]; | 2159 | 2159 |
| 2160 | | - if (!cache_struct_converter(format, &s_object)) { | | 2160 | + if (!cache_struct_converter(format, (PyStructObject **)&s_object)) { | 2161 | 2161 | return NULL; | 2162 | 2162 | } | 2163 | 2163 | result = s_pack(s_object, args + 1, nargs - 1); | @@ -2185,7 +2185,7 @@ pack_into(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | 2185 | 2185 | } | 2186 | 2186 | format = args[0]; | 2187 | 2187 |
| 2188 | | - if (!cache_struct_converter(format, &s_object)) { | | 2188 | + if (!cache_struct_converter(format, (PyStructObject **)&s_object)) { | 2189 | 2189 | return NULL; | 2190 | 2190 | } | 2191 | 2191 | result = s_pack_into(s_object, args + 1, nargs - 1); | |
Collapse file Copy file name to clipboardExpand all lines: Modules/cjkcodecs/clinic/multibytecodec.c.h +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -150,9 +150,11 @@ _multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoder | 150 | 150 | PyObject *return_value = NULL; | 151 | 151 | PyLongObject *statelong; | 152 | 152 |
| 153 | | - if (!PyArg_Parse(arg, "O!:setstate", &PyLong_Type, &statelong)) { | | 153 | + if (!PyLong_Check(arg)) { | | 154 | + _PyArg_BadArgument("setstate", "int", arg); | 154 | 155 | goto exit; | 155 | 156 | } | | 157 | + statelong = (PyLongObject *)arg; | 156 | 158 | return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong); | 157 | 159 |
| 158 | 160 | exit: | @@ -248,9 +250,11 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoder | 248 | 250 | PyObject *return_value = NULL; | 249 | 251 | PyObject *state; | 250 | 252 |
| 251 | | - if (!PyArg_Parse(arg, "O!:setstate", &PyTuple_Type, &state)) { | | 253 | + if (!PyTuple_Check(arg)) { | | 254 | + _PyArg_BadArgument("setstate", "tuple", arg); | 252 | 255 | goto exit; | 253 | 256 | } | | 257 | + state = arg; | 254 | 258 | return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state); | 255 | 259 |
| 256 | 260 | exit: | @@ -418,4 +422,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__, | 418 | 422 |
| 419 | 423 | #define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \ | 420 | 424 | {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__}, | 421 | | -/*[clinic end generated code: output=4c1dc8015ee5abb4 input=a9049054013a1b77]*/ | | 425 | +/*[clinic end generated code: output=a94364d0965adf1d input=a9049054013a1b77]*/ |
|