From 3191391515824fa7f3c573d807f1034c6a28fab3 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 14 Mar 2019 10:32:22 +0200 Subject: bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-12058) --- Doc/whatsnew/3.8.rst | 5 + Include/modsupport.h | 12 + Lib/test/clinic.test | 1263 +++++++++++++++++++ Modules/_blake2/clinic/blake2b_impl.c.h | 148 ++- Modules/_blake2/clinic/blake2s_impl.c.h | 148 ++- Modules/_io/clinic/_iomodule.c.h | 131 +- Modules/_io/clinic/bufferedio.c.h | 98 +- Modules/_io/clinic/bytesio.c.h | 17 +- Modules/_io/clinic/fileio.c.h | 50 +- Modules/_io/clinic/stringio.c.h | 23 +- Modules/_io/clinic/textio.c.h | 176 ++- Modules/_io/clinic/winconsoleio.c.h | 50 +- Modules/_multiprocessing/clinic/posixshmem.c.h | 55 +- Modules/cjkcodecs/clinic/multibytecodec.c.h | 120 +- Modules/clinic/_asynciomodule.c.h | 145 ++- Modules/clinic/_bz2module.c.h | 38 +- Modules/clinic/_codecsmodule.c.h | 90 +- Modules/clinic/_cursesmodule.c.h | 46 +- Modules/clinic/_datetimemodule.c.h | 15 +- Modules/clinic/_elementtree.c.h | 157 ++- Modules/clinic/_hashopenssl.c.h | 183 ++- Modules/clinic/_lzmamodule.c.h | 73 +- Modules/clinic/_opcode.c.h | 30 +- Modules/clinic/_pickle.c.h | 243 +++- Modules/clinic/_queuemodule.c.h | 55 +- Modules/clinic/_sre.c.h | 489 +++++++- Modules/clinic/_ssl.c.h | 248 +++- Modules/clinic/_struct.c.h | 87 +- Modules/clinic/binascii.c.h | 138 ++- Modules/clinic/cmathmodule.c.h | 35 +- Modules/clinic/gcmodule.c.h | 38 +- Modules/clinic/grpmodule.c.h | 25 +- Modules/clinic/itertoolsmodule.c.h | 146 ++- Modules/clinic/mathmodule.c.h | 49 +- Modules/clinic/md5module.c.h | 15 +- Modules/clinic/posixmodule.c.h | 1551 ++++++++++++++++++++---- Modules/clinic/pyexpat.c.h | 61 +- Modules/clinic/selectmodule.c.h | 119 +- Modules/clinic/sha1module.c.h | 15 +- Modules/clinic/sha256module.c.h | 28 +- Modules/clinic/sha512module.c.h | 28 +- Modules/clinic/zlibmodule.c.h | 204 +++- Objects/clinic/bytearrayobject.c.h | 150 ++- Objects/clinic/bytesobject.c.h | 150 ++- Objects/clinic/complexobject.c.h | 23 +- Objects/clinic/descrobject.c.h | 45 +- Objects/clinic/enumobject.c.h | 18 +- Objects/clinic/funcobject.c.h | 39 +- Objects/clinic/listobject.c.h | 29 +- Objects/clinic/longobject.c.h | 89 +- Objects/clinic/moduleobject.c.h | 25 +- Objects/clinic/odictobject.c.h | 63 +- Objects/clinic/structseq.c.h | 18 +- Objects/clinic/unicodeobject.c.h | 157 ++- Objects/stringlib/clinic/transmogrify.h.h | 23 +- PC/clinic/_testconsole.c.h | 23 +- PC/clinic/winreg.c.h | 12 +- PC/clinic/winsound.c.h | 65 +- Python/clinic/_warnings.c.h | 44 +- Python/clinic/bltinmodule.c.h | 110 +- Python/clinic/import.c.h | 25 +- Python/clinic/sysmodule.c.h | 18 +- Python/clinic/traceback.c.h | 35 +- Python/getargs.c | 320 ++++- Tools/clinic/clinic.py | 196 ++- 65 files changed, 7461 insertions(+), 863 deletions(-) diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 4adeded..31ea0d1 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -442,6 +442,11 @@ Optimizations (Contributed by Stefan Behnel, Pablo Galindo Salgado, Raymond Hettinger, Neil Schemenauer, and Serhiy Storchaka in :issue:`36012`.) +* Reduced an overhead of converting arguments passed to many builtin functions + and methods. This sped up calling some simple builtin functions and + methods up to 20--50%. (Contributed by Serhiy Storchaka in :issue:`23867`, + :issue:`35582` and :issue:`36127`.) + Build and C API Changes ======================= diff --git a/Include/modsupport.h b/Include/modsupport.h index f17060c..66a5ec8 100644 --- a/Include/modsupport.h +++ b/Include/modsupport.h @@ -118,6 +118,18 @@ PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords( ...); PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *, struct _PyArg_Parser *, va_list); +PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( + PyObject *const *args, Py_ssize_t nargs, + PyObject *kwargs, PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, int maxpos, int minkw, + PyObject **buf); +#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ + (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ + (minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \ + _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ + (minpos), (maxpos), (minkw), (buf))) + void _PyArg_Fini(void); #endif /* Py_LIMITED_API */ diff --git a/Lib/test/clinic.test b/Lib/test/clinic.test index b8f2331..62c2f00 100644 --- a/Lib/test/clinic.test +++ b/Lib/test/clinic.test @@ -3,6 +3,7 @@ output preset block [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=3c81ac2402d06a8b]*/ + /*[clinic input] test_object_converter @@ -59,6 +60,7 @@ test_object_converter_impl(PyObject *module, PyObject *a, PyObject *b, PyObject *c, PyUnicode_Object *d) /*[clinic end generated code: output=f2c26174b3d46e94 input=005e6a8a711a869b]*/ + /*[clinic input] test_object_converter_one_arg @@ -79,6 +81,7 @@ static PyObject * test_object_converter_one_arg(PyObject *module, PyObject *a) /*[clinic end generated code: output=6da755f8502139df input=d635d92a421f1ca3]*/ + /*[clinic input] test_objects_converter @@ -125,6 +128,7 @@ static PyObject * test_objects_converter_impl(PyObject *module, PyObject *a, PyObject *b) /*[clinic end generated code: output=58009c0e42b4834e input=4cbb3d9edd2a36f3]*/ + /*[clinic input] test_object_converter_subclass_of @@ -238,6 +242,7 @@ test_object_converter_subclass_of_impl(PyObject *module, PyObject *a, PyObject *h, PyObject *i, PyObject *j) /*[clinic end generated code: output=99691bda8eeda6d6 input=31b06b772d5f983e]*/ + /*[clinic input] test_PyBytesObject_converter @@ -278,6 +283,7 @@ static PyObject * test_PyBytesObject_converter_impl(PyObject *module, PyBytesObject *a) /*[clinic end generated code: output=5d9a301c1df24eb5 input=12b10c7cb5750400]*/ + /*[clinic input] test_PyByteArrayObject_converter @@ -318,6 +324,7 @@ static PyObject * test_PyByteArrayObject_converter_impl(PyObject *module, PyByteArrayObject *a) /*[clinic end generated code: output=9455d06f4f09637b input=5a657da535d194ae]*/ + /*[clinic input] test_unicode_converter @@ -361,6 +368,7 @@ static PyObject * test_unicode_converter_impl(PyObject *module, PyObject *a) /*[clinic end generated code: output=9275c04fe204f4c5 input=aa33612df92aa9c5]*/ + /*[clinic input] test_bool_converter @@ -430,6 +438,7 @@ static PyObject * test_bool_converter_impl(PyObject *module, int a, int b, int c) /*[clinic end generated code: output=25f20963894256a1 input=939854fa9f248c60]*/ + /*[clinic input] test_char_converter @@ -683,6 +692,7 @@ test_char_converter_impl(PyObject *module, char a, char b, char c, char d, char k, char l, char m, char n) /*[clinic end generated code: output=e041d687555e0a5d input=e42330417a44feac]*/ + /*[clinic input] test_unsigned_char_converter @@ -799,6 +809,7 @@ test_unsigned_char_converter_impl(PyObject *module, unsigned char a, unsigned char b, unsigned char c) /*[clinic end generated code: output=ebf905c5c9414762 input=021414060993e289]*/ + /*[clinic input] test_short_converter @@ -865,6 +876,7 @@ static PyObject * test_short_converter_impl(PyObject *module, short a) /*[clinic end generated code: output=86fe1a1496a7ff20 input=6a8a7a509a498ff4]*/ + /*[clinic input] test_unsigned_short_converter @@ -934,6 +946,7 @@ test_unsigned_short_converter_impl(PyObject *module, unsigned short a, unsigned short b, unsigned short c) /*[clinic end generated code: output=3779fe104319e3ae input=cdfd8eff3d9176b4]*/ + /*[clinic input] test_int_converter @@ -1030,6 +1043,7 @@ static PyObject * test_int_converter_impl(PyObject *module, int a, int b, int c, myenum d) /*[clinic end generated code: output=de74e24e85a669a5 input=d20541fc1ca0553e]*/ + /*[clinic input] test_unsigned_int_converter @@ -1099,6 +1113,7 @@ test_unsigned_int_converter_impl(PyObject *module, unsigned int a, unsigned int b, unsigned int c) /*[clinic end generated code: output=189176ce67c7d2e7 input=5533534828b62fc0]*/ + /*[clinic input] test_long_converter @@ -1150,6 +1165,7 @@ static PyObject * test_long_converter_impl(PyObject *module, long a) /*[clinic end generated code: output=44cd8823f59d116b input=d2179e3c9cdcde89]*/ + /*[clinic input] test_unsigned_long_converter @@ -1215,6 +1231,7 @@ test_unsigned_long_converter_impl(PyObject *module, unsigned long a, unsigned long b, unsigned long c) /*[clinic end generated code: output=1c05c871c0309e08 input=f450d94cae1ef73b]*/ + /*[clinic input] test_long_long_converter @@ -1266,6 +1283,7 @@ static PyObject * test_long_long_converter_impl(PyObject *module, long long a) /*[clinic end generated code: output=3e8083f3aee4f18a input=d5fc81577ff4dd02]*/ + /*[clinic input] test_unsigned_long_long_converter @@ -1335,6 +1353,7 @@ test_unsigned_long_long_converter_impl(PyObject *module, unsigned long long c) /*[clinic end generated code: output=0a9b17fb824e28eb input=a15115dc41866ff4]*/ + /*[clinic input] test_Py_ssize_t_converter @@ -1426,6 +1445,7 @@ test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b, Py_ssize_t c) /*[clinic end generated code: output=a46d2aaf40c10398 input=3855f184bb3f299d]*/ + /*[clinic input] test_slice_index_converter @@ -1489,6 +1509,7 @@ test_slice_index_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b, Py_ssize_t c) /*[clinic end generated code: output=2148703cd3c6e941 input=edeadb0ee126f531]*/ + /*[clinic input] test_size_t_converter @@ -1534,6 +1555,7 @@ static PyObject * test_size_t_converter_impl(PyObject *module, size_t a) /*[clinic end generated code: output=8a91a9ca8a92dabb input=52e93a0fed0f1fb3]*/ + /*[clinic input] test_float_converter @@ -1580,6 +1602,7 @@ static PyObject * test_float_converter_impl(PyObject *module, float a) /*[clinic end generated code: output=8293566b2ec1fc52 input=259c0d98eca35034]*/ + /*[clinic input] test_double_converter @@ -1626,6 +1649,7 @@ static PyObject * test_double_converter_impl(PyObject *module, double a) /*[clinic end generated code: output=487081a9b8da67ab input=c6a9945706a41c27]*/ + /*[clinic input] test_Py_complex_converter @@ -1665,6 +1689,7 @@ static PyObject * test_Py_complex_converter_impl(PyObject *module, Py_complex a) /*[clinic end generated code: output=c2ecbec2144ca540 input=070f216a515beb79]*/ + /*[clinic input] test_str_converter @@ -1730,6 +1755,7 @@ test_str_converter_impl(PyObject *module, const char *a, const char *b, const char *h, Py_ssize_clean_t h_length) /*[clinic end generated code: output=8415d82c56154307 input=8afe9da8185cd38c]*/ + /*[clinic input] test_str_converter_encoding @@ -1804,6 +1830,7 @@ test_str_converter_encoding_impl(PyObject *module, char *a, char *b, char *c, Py_ssize_clean_t e_length) /*[clinic end generated code: output=f579dd9e795a364e input=eb4c38e1f898f402]*/ + /*[clinic input] test_Py_UNICODE_converter @@ -1863,6 +1890,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a, Py_ssize_clean_t e_length) /*[clinic end generated code: output=dd0a09a1b772e57b input=064a3b68ad7f04b0]*/ + /*[clinic input] test_Py_buffer_converter @@ -1932,3 +1960,1238 @@ static PyObject * test_Py_buffer_converter_impl(PyObject *module, Py_buffer *a, Py_buffer *b, Py_buffer *c, Py_buffer *d, Py_buffer *e) /*[clinic end generated code: output=5760c82faa2ed61f input=6a9da0f56f9525fd]*/ + + +/*[clinic input] +test_keywords + + a: object + b: object + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_keywords__doc__, +"test_keywords($module, /, a, b)\n" +"--\n" +"\n"); + +#define TEST_KEYWORDS_METHODDEF \ + {"test_keywords", (PyCFunction)(void(*)(void))test_keywords, METH_FASTCALL|METH_KEYWORDS, test_keywords__doc__}, + +static PyObject * +test_keywords_impl(PyObject *module, PyObject *a, PyObject *b); + +static PyObject * +test_keywords(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "b", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_keywords", 0}; + PyObject *argsbuf[2]; + PyObject *a; + PyObject *b; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + return_value = test_keywords_impl(module, a, b); + +exit: + return return_value; +} + +static PyObject * +test_keywords_impl(PyObject *module, PyObject *a, PyObject *b) +/*[clinic end generated code: output=4be6cf045ea8242e input=0d3484844749c05b]*/ + + +/*[clinic input] +test_keywords_kwonly + + a: object + * + b: object + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_keywords_kwonly__doc__, +"test_keywords_kwonly($module, /, a, *, b)\n" +"--\n" +"\n"); + +#define TEST_KEYWORDS_KWONLY_METHODDEF \ + {"test_keywords_kwonly", (PyCFunction)(void(*)(void))test_keywords_kwonly, METH_FASTCALL|METH_KEYWORDS, test_keywords_kwonly__doc__}, + +static PyObject * +test_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b); + +static PyObject * +test_keywords_kwonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "b", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_keywords_kwonly", 0}; + PyObject *argsbuf[2]; + PyObject *a; + PyObject *b; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 1, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + return_value = test_keywords_kwonly_impl(module, a, b); + +exit: + return return_value; +} + +static PyObject * +test_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b) +/*[clinic end generated code: output=d63c4977a7a80713 input=384adc78bfa0bff7]*/ + + +/*[clinic input] +test_keywords_opt + + a: object + b: object = None + c: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_keywords_opt__doc__, +"test_keywords_opt($module, /, a, b=None, c=None)\n" +"--\n" +"\n"); + +#define TEST_KEYWORDS_OPT_METHODDEF \ + {"test_keywords_opt", (PyCFunction)(void(*)(void))test_keywords_opt, METH_FASTCALL|METH_KEYWORDS, test_keywords_opt__doc__}, + +static PyObject * +test_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c); + +static PyObject * +test_keywords_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "b", "c", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_keywords_opt", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + b = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + c = args[2]; +skip_optional_pos: + return_value = test_keywords_opt_impl(module, a, b, c); + +exit: + return return_value; +} + +static PyObject * +test_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c) +/*[clinic end generated code: output=e5e50d114d8fc10a input=eda7964f784f4607]*/ + + +/*[clinic input] +test_keywords_opt_kwonly + + a: object + b: object = None + * + c: object = None + d: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_keywords_opt_kwonly__doc__, +"test_keywords_opt_kwonly($module, /, a, b=None, *, c=None, d=None)\n" +"--\n" +"\n"); + +#define TEST_KEYWORDS_OPT_KWONLY_METHODDEF \ + {"test_keywords_opt_kwonly", (PyCFunction)(void(*)(void))test_keywords_opt_kwonly, METH_FASTCALL|METH_KEYWORDS, test_keywords_opt_kwonly__doc__}, + +static PyObject * +test_keywords_opt_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d); + +static PyObject * +test_keywords_opt_kwonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "b", "c", "d", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_keywords_opt_kwonly", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + b = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + d = args[3]; +skip_optional_kwonly: + return_value = test_keywords_opt_kwonly_impl(module, a, b, c, d); + +exit: + return return_value; +} + +static PyObject * +test_keywords_opt_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d) +/*[clinic end generated code: output=3f065cb8309b9317 input=209387a4815e5082]*/ + + +/*[clinic input] +test_keywords_kwonly_opt + + a: object + * + b: object = None + c: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_keywords_kwonly_opt__doc__, +"test_keywords_kwonly_opt($module, /, a, *, b=None, c=None)\n" +"--\n" +"\n"); + +#define TEST_KEYWORDS_KWONLY_OPT_METHODDEF \ + {"test_keywords_kwonly_opt", (PyCFunction)(void(*)(void))test_keywords_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_keywords_kwonly_opt__doc__}, + +static PyObject * +test_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c); + +static PyObject * +test_keywords_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"a", "b", "c", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_keywords_kwonly_opt", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + b = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + c = args[2]; +skip_optional_kwonly: + return_value = test_keywords_kwonly_opt_impl(module, a, b, c); + +exit: + return return_value; +} + +static PyObject * +test_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c) +/*[clinic end generated code: output=94edba5484e1681e input=18393cc64fa000f4]*/ + + +/*[clinic input] +test_posonly_keywords + + a: object + / + b: object + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords__doc__, +"test_posonly_keywords($module, a, /, b)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_METHODDEF \ + {"test_posonly_keywords", (PyCFunction)(void(*)(void))test_posonly_keywords, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords__doc__}, + +static PyObject * +test_posonly_keywords_impl(PyObject *module, PyObject *a, PyObject *b); + +static PyObject * +test_posonly_keywords(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords", 0}; + PyObject *argsbuf[2]; + PyObject *a; + PyObject *b; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + return_value = test_posonly_keywords_impl(module, a, b); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_impl(PyObject *module, PyObject *a, PyObject *b) +/*[clinic end generated code: output=eca1507f0182ffb0 input=1767b0ebdf06060e]*/ + + +/*[clinic input] +test_posonly_kwonly + + a: object + / + * + c: object + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_kwonly__doc__, +"test_posonly_kwonly($module, a, /, *, c)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KWONLY_METHODDEF \ + {"test_posonly_kwonly", (PyCFunction)(void(*)(void))test_posonly_kwonly, METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly__doc__}, + +static PyObject * +test_posonly_kwonly_impl(PyObject *module, PyObject *a, PyObject *c); + +static PyObject * +test_posonly_kwonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "c", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_kwonly", 0}; + PyObject *argsbuf[2]; + PyObject *a; + PyObject *c; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 1, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + c = args[1]; + return_value = test_posonly_kwonly_impl(module, a, c); + +exit: + return return_value; +} + +static PyObject * +test_posonly_kwonly_impl(PyObject *module, PyObject *a, PyObject *c) +/*[clinic end generated code: output=3e14655646b66e9a input=9042f2818f664839]*/ + + +/*[clinic input] +test_posonly_keywords_kwonly + + a: object + / + b: object + * + c: object + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_kwonly__doc__, +"test_posonly_keywords_kwonly($module, a, /, b, *, c)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_KWONLY_METHODDEF \ + {"test_posonly_keywords_kwonly", (PyCFunction)(void(*)(void))test_posonly_keywords_kwonly, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly__doc__}, + +static PyObject * +test_posonly_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c); + +static PyObject * +test_posonly_keywords_kwonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_kwonly", 0}; + PyObject *argsbuf[3]; + PyObject *a; + PyObject *b; + PyObject *c; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 1, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + c = args[2]; + return_value = test_posonly_keywords_kwonly_impl(module, a, b, c); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_kwonly_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c) +/*[clinic end generated code: output=de57172fc97a626e input=29546ebdca492fea]*/ + + +/*[clinic input] +test_posonly_keywords_opt + + a: object + / + b: object + c: object = None + d: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_opt__doc__, +"test_posonly_keywords_opt($module, a, /, b, c=None, d=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_OPT_METHODDEF \ + {"test_posonly_keywords_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt__doc__}, + +static PyObject * +test_posonly_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d); + +static PyObject * +test_posonly_keywords_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", "d", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_opt", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *b; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + d = args[3]; +skip_optional_pos: + return_value = test_posonly_keywords_opt_impl(module, a, b, c, d); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d) +/*[clinic end generated code: output=8bc6b44a25d4b716 input=cdf5a9625e554e9b]*/ + + +/*[clinic input] +test_posonly_keywords_opt2 + + a: object + / + b: object = None + c: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_opt2__doc__, +"test_posonly_keywords_opt2($module, a, /, b=None, c=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_OPT2_METHODDEF \ + {"test_posonly_keywords_opt2", (PyCFunction)(void(*)(void))test_posonly_keywords_opt2, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt2__doc__}, + +static PyObject * +test_posonly_keywords_opt2_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c); + +static PyObject * +test_posonly_keywords_opt2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_opt2", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + b = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + c = args[2]; +skip_optional_pos: + return_value = test_posonly_keywords_opt2_impl(module, a, b, c); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_opt2_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c) +/*[clinic end generated code: output=a870c45a6510ba91 input=1581299d21d16f14]*/ + + +/*[clinic input] +test_posonly_opt_keywords_opt + + a: object + b: object = None + / + c: object = None + d: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_opt_keywords_opt__doc__, +"test_posonly_opt_keywords_opt($module, a, b=None, /, c=None, d=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_OPT_KEYWORDS_OPT_METHODDEF \ + {"test_posonly_opt_keywords_opt", (PyCFunction)(void(*)(void))test_posonly_opt_keywords_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_keywords_opt__doc__}, + +static PyObject * +test_posonly_opt_keywords_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, PyObject *d); + +static PyObject * +test_posonly_opt_keywords_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", "c", "d", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_opt_keywords_opt", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (nargs < 2) { + goto skip_optional_posonly; + } + noptargs--; + b = args[1]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + d = args[3]; +skip_optional_pos: + return_value = test_posonly_opt_keywords_opt_impl(module, a, b, c, d); + +exit: + return return_value; +} + +static PyObject * +test_posonly_opt_keywords_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, PyObject *d) +/*[clinic end generated code: output=9ae3d52e071d3b7f input=408798ec3d42949f]*/ + + +/*[clinic input] +test_posonly_kwonly_opt + + a: object + / + * + b: object + c: object = None + d: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_kwonly_opt__doc__, +"test_posonly_kwonly_opt($module, a, /, *, b, c=None, d=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KWONLY_OPT_METHODDEF \ + {"test_posonly_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly_opt__doc__}, + +static PyObject * +test_posonly_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d); + +static PyObject * +test_posonly_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", "d", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_kwonly_opt", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *b; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 1, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + d = args[3]; +skip_optional_kwonly: + return_value = test_posonly_kwonly_opt_impl(module, a, b, c, d); + +exit: + return return_value; +} + +static PyObject * +test_posonly_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d) +/*[clinic end generated code: output=fb001f586ba68549 input=8d8e5643bbbc2309]*/ + + +/*[clinic input] +test_posonly_kwonly_opt2 + + a: object + / + * + b: object = None + c: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_kwonly_opt2__doc__, +"test_posonly_kwonly_opt2($module, a, /, *, b=None, c=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KWONLY_OPT2_METHODDEF \ + {"test_posonly_kwonly_opt2", (PyCFunction)(void(*)(void))test_posonly_kwonly_opt2, METH_FASTCALL|METH_KEYWORDS, test_posonly_kwonly_opt2__doc__}, + +static PyObject * +test_posonly_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c); + +static PyObject * +test_posonly_kwonly_opt2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_kwonly_opt2", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + b = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + c = args[2]; +skip_optional_kwonly: + return_value = test_posonly_kwonly_opt2_impl(module, a, b, c); + +exit: + return return_value; +} + +static PyObject * +test_posonly_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c) +/*[clinic end generated code: output=51aae7cac77b458a input=f7e5eed94f75fff0]*/ + + +/*[clinic input] +test_posonly_opt_kwonly_opt + + a: object + b: object = None + / + * + c: object = None + d: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_opt_kwonly_opt__doc__, +"test_posonly_opt_kwonly_opt($module, a, b=None, /, *, c=None, d=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_OPT_KWONLY_OPT_METHODDEF \ + {"test_posonly_opt_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_opt_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_kwonly_opt__doc__}, + +static PyObject * +test_posonly_opt_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d); + +static PyObject * +test_posonly_opt_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", "c", "d", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_opt_kwonly_opt", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (nargs < 2) { + goto skip_optional_posonly; + } + noptargs--; + b = args[1]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + d = args[3]; +skip_optional_kwonly: + return_value = test_posonly_opt_kwonly_opt_impl(module, a, b, c, d); + +exit: + return return_value; +} + +static PyObject * +test_posonly_opt_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *b, + PyObject *c, PyObject *d) +/*[clinic end generated code: output=68844c45143d1668 input=1e557dc979d120fd]*/ + + +/*[clinic input] +test_posonly_keywords_kwonly_opt + + a: object + / + b: object + * + c: object + d: object = None + e: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_kwonly_opt__doc__, +"test_posonly_keywords_kwonly_opt($module, a, /, b, *, c, d=None, e=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_KWONLY_OPT_METHODDEF \ + {"test_posonly_keywords_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly_opt__doc__}, + +static PyObject * +test_posonly_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, PyObject *d, + PyObject *e); + +static PyObject * +test_posonly_keywords_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", "d", "e", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_kwonly_opt", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; + PyObject *a; + PyObject *b; + PyObject *c; + PyObject *d = Py_None; + PyObject *e = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 1, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + c = args[2]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + d = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + e = args[4]; +skip_optional_kwonly: + return_value = test_posonly_keywords_kwonly_opt_impl(module, a, b, c, d, e); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, PyObject *d, + PyObject *e) +/*[clinic end generated code: output=996ff645551897ac input=c3884a4f956fdc89]*/ + + +/*[clinic input] +test_posonly_keywords_kwonly_opt2 + + a: object + / + b: object + * + c: object = None + d: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_kwonly_opt2__doc__, +"test_posonly_keywords_kwonly_opt2($module, a, /, b, *, c=None, d=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_KWONLY_OPT2_METHODDEF \ + {"test_posonly_keywords_kwonly_opt2", (PyCFunction)(void(*)(void))test_posonly_keywords_kwonly_opt2, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_kwonly_opt2__doc__}, + +static PyObject * +test_posonly_keywords_kwonly_opt2_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, PyObject *d); + +static PyObject * +test_posonly_keywords_kwonly_opt2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", "d", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_kwonly_opt2", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *b; + PyObject *c = Py_None; + PyObject *d = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + d = args[3]; +skip_optional_kwonly: + return_value = test_posonly_keywords_kwonly_opt2_impl(module, a, b, c, d); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_kwonly_opt2_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, PyObject *d) +/*[clinic end generated code: output=e5a3e992fd4b28b3 input=68d01d7c0f6dafb0]*/ + + +/*[clinic input] +test_posonly_keywords_opt_kwonly_opt + + a: object + / + b: object + c: object = None + * + d: object = None + e: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_opt_kwonly_opt__doc__, +"test_posonly_keywords_opt_kwonly_opt($module, a, /, b, c=None, *,\n" +" d=None, e=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_OPT_KWONLY_OPT_METHODDEF \ + {"test_posonly_keywords_opt_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_opt_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt_kwonly_opt__doc__}, + +static PyObject * +test_posonly_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, + PyObject *d, PyObject *e); + +static PyObject * +test_posonly_keywords_opt_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", "d", "e", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_opt_kwonly_opt", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + PyObject *a; + PyObject *b; + PyObject *c = Py_None; + PyObject *d = Py_None; + PyObject *e = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + b = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + d = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + e = args[4]; +skip_optional_kwonly: + return_value = test_posonly_keywords_opt_kwonly_opt_impl(module, a, b, c, d, e); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, + PyObject *d, PyObject *e) +/*[clinic end generated code: output=ff9fb6c3d2cbbaa4 input=d0883d45876f186c]*/ + + +/*[clinic input] +test_posonly_keywords_opt2_kwonly_opt + + a: object + / + b: object = None + c: object = None + * + d: object = None + e: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_keywords_opt2_kwonly_opt__doc__, +"test_posonly_keywords_opt2_kwonly_opt($module, a, /, b=None, c=None, *,\n" +" d=None, e=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_KEYWORDS_OPT2_KWONLY_OPT_METHODDEF \ + {"test_posonly_keywords_opt2_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_keywords_opt2_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_keywords_opt2_kwonly_opt__doc__}, + +static PyObject * +test_posonly_keywords_opt2_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, + PyObject *d, PyObject *e); + +static PyObject * +test_posonly_keywords_opt2_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "b", "c", "d", "e", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_keywords_opt2_kwonly_opt", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + PyObject *d = Py_None; + PyObject *e = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + b = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + d = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + e = args[4]; +skip_optional_kwonly: + return_value = test_posonly_keywords_opt2_kwonly_opt_impl(module, a, b, c, d, e); + +exit: + return return_value; +} + +static PyObject * +test_posonly_keywords_opt2_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, + PyObject *d, PyObject *e) +/*[clinic end generated code: output=c809d7a84a2205e1 input=c95e2e1ec93035ad]*/ + + +/*[clinic input] +test_posonly_opt_keywords_opt_kwonly_opt + + a: object + b: object = None + / + c: object = None + d: object = None + * + e: object = None + f: object = None + +[clinic start generated code]*/ + +PyDoc_STRVAR(test_posonly_opt_keywords_opt_kwonly_opt__doc__, +"test_posonly_opt_keywords_opt_kwonly_opt($module, a, b=None, /, c=None,\n" +" d=None, *, e=None, f=None)\n" +"--\n" +"\n"); + +#define TEST_POSONLY_OPT_KEYWORDS_OPT_KWONLY_OPT_METHODDEF \ + {"test_posonly_opt_keywords_opt_kwonly_opt", (PyCFunction)(void(*)(void))test_posonly_opt_keywords_opt_kwonly_opt, METH_FASTCALL|METH_KEYWORDS, test_posonly_opt_keywords_opt_kwonly_opt__doc__}, + +static PyObject * +test_posonly_opt_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, + PyObject *d, PyObject *e, + PyObject *f); + +static PyObject * +test_posonly_opt_keywords_opt_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", "c", "d", "e", "f", NULL}; + static _PyArg_Parser _parser = {NULL, _keywords, "test_posonly_opt_keywords_opt_kwonly_opt", 0}; + PyObject *argsbuf[6]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + PyObject *a; + PyObject *b = Py_None; + PyObject *c = Py_None; + PyObject *d = Py_None; + PyObject *e = Py_None; + PyObject *f = Py_None; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); + if (!args) { + goto exit; + } + a = args[0]; + if (nargs < 2) { + goto skip_optional_posonly; + } + noptargs--; + b = args[1]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + c = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + d = args[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[4]) { + e = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + f = args[5]; +skip_optional_kwonly: + return_value = test_posonly_opt_keywords_opt_kwonly_opt_impl(module, a, b, c, d, e, f); + +exit: + return return_value; +} + +static PyObject * +test_posonly_opt_keywords_opt_kwonly_opt_impl(PyObject *module, PyObject *a, + PyObject *b, PyObject *c, + PyObject *d, PyObject *e, + PyObject *f) +/*[clinic end generated code: output=719e4f6c224402d4 input=9914857713c5bbf8]*/ diff --git a/Modules/_blake2/clinic/blake2b_impl.c.h b/Modules/_blake2/clinic/blake2b_impl.c.h index 3315bf9..09fe004 100644 --- a/Modules/_blake2/clinic/blake2b_impl.c.h +++ b/Modules/_blake2/clinic/blake2b_impl.c.h @@ -22,7 +22,11 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", NULL}; - static _PyArg_Parser _parser = {"|O$iy*y*y*iiO&O&iip:blake2b", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "blake2b", 0}; + PyObject *argsbuf[12]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *data = NULL; int digest_size = BLAKE2B_OUTBYTES; Py_buffer key = {NULL, NULL}; @@ -36,10 +40,146 @@ py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) int inner_size = 0; int last_node = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &data, &digest_size, &key, &salt, &person, &fanout, &depth, _PyLong_UnsignedLong_Converter, &leaf_size, _PyLong_UnsignedLongLong_Converter, &node_offset, &node_depth, &inner_size, &last_node)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + if (nargs < 1) { + goto skip_optional_posonly; + } + noptargs--; + data = fastargs[0]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + digest_size = _PyLong_AsInt(fastargs[1]); + if (digest_size == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + if (PyObject_GetBuffer(fastargs[2], &key, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&key, 'C')) { + _PyArg_BadArgument("blake2b", 3, "contiguous buffer", fastargs[2]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + if (PyObject_GetBuffer(fastargs[3], &salt, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&salt, 'C')) { + _PyArg_BadArgument("blake2b", 4, "contiguous buffer", fastargs[3]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[4]) { + if (PyObject_GetBuffer(fastargs[4], &person, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&person, 'C')) { + _PyArg_BadArgument("blake2b", 5, "contiguous buffer", fastargs[4]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[5]) { + if (PyFloat_Check(fastargs[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fanout = _PyLong_AsInt(fastargs[5]); + if (fanout == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[6]) { + if (PyFloat_Check(fastargs[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + depth = _PyLong_AsInt(fastargs[6]); + if (depth == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[7]) { + if (!_PyLong_UnsignedLong_Converter(fastargs[7], &leaf_size)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[8]) { + if (!_PyLong_UnsignedLongLong_Converter(fastargs[8], &node_offset)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[9]) { + if (PyFloat_Check(fastargs[9])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + node_depth = _PyLong_AsInt(fastargs[9]); + if (node_depth == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[10]) { + if (PyFloat_Check(fastargs[10])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + inner_size = _PyLong_AsInt(fastargs[10]); + if (inner_size == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + last_node = PyObject_IsTrue(fastargs[11]); + if (last_node < 0) { + goto exit; + } +skip_optional_kwonly: return_value = py_blake2b_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size, node_offset, node_depth, inner_size, last_node); exit: @@ -121,4 +261,4 @@ _blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored)) { return _blake2_blake2b_hexdigest_impl(self); } -/*[clinic end generated code: output=39c77de2142faa12 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a91d182ce1109f34 input=a9049054013a1b77]*/ diff --git a/Modules/_blake2/clinic/blake2s_impl.c.h b/Modules/_blake2/clinic/blake2s_impl.c.h index 23d19ec..92739a1 100644 --- a/Modules/_blake2/clinic/blake2s_impl.c.h +++ b/Modules/_blake2/clinic/blake2s_impl.c.h @@ -22,7 +22,11 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", NULL}; - static _PyArg_Parser _parser = {"|O$iy*y*y*iiO&O&iip:blake2s", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "blake2s", 0}; + PyObject *argsbuf[12]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *data = NULL; int digest_size = BLAKE2S_OUTBYTES; Py_buffer key = {NULL, NULL}; @@ -36,10 +40,146 @@ py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) int inner_size = 0; int last_node = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &data, &digest_size, &key, &salt, &person, &fanout, &depth, _PyLong_UnsignedLong_Converter, &leaf_size, _PyLong_UnsignedLongLong_Converter, &node_offset, &node_depth, &inner_size, &last_node)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + if (nargs < 1) { + goto skip_optional_posonly; + } + noptargs--; + data = fastargs[0]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + digest_size = _PyLong_AsInt(fastargs[1]); + if (digest_size == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + if (PyObject_GetBuffer(fastargs[2], &key, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&key, 'C')) { + _PyArg_BadArgument("blake2s", 3, "contiguous buffer", fastargs[2]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + if (PyObject_GetBuffer(fastargs[3], &salt, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&salt, 'C')) { + _PyArg_BadArgument("blake2s", 4, "contiguous buffer", fastargs[3]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[4]) { + if (PyObject_GetBuffer(fastargs[4], &person, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&person, 'C')) { + _PyArg_BadArgument("blake2s", 5, "contiguous buffer", fastargs[4]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[5]) { + if (PyFloat_Check(fastargs[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fanout = _PyLong_AsInt(fastargs[5]); + if (fanout == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[6]) { + if (PyFloat_Check(fastargs[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + depth = _PyLong_AsInt(fastargs[6]); + if (depth == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[7]) { + if (!_PyLong_UnsignedLong_Converter(fastargs[7], &leaf_size)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[8]) { + if (!_PyLong_UnsignedLongLong_Converter(fastargs[8], &node_offset)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[9]) { + if (PyFloat_Check(fastargs[9])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + node_depth = _PyLong_AsInt(fastargs[9]); + if (node_depth == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[10]) { + if (PyFloat_Check(fastargs[10])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + inner_size = _PyLong_AsInt(fastargs[10]); + if (inner_size == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + last_node = PyObject_IsTrue(fastargs[11]); + if (last_node < 0) { + goto exit; + } +skip_optional_kwonly: return_value = py_blake2s_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size, node_offset, node_depth, inner_size, last_node); exit: @@ -121,4 +261,4 @@ _blake2_blake2s_hexdigest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored)) { return _blake2_blake2s_hexdigest_impl(self); } -/*[clinic end generated code: output=a31a1d56f0e0781f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ae8e9b7301d092b4 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h index f03e84e..990c81c 100644 --- a/Modules/_io/clinic/_iomodule.c.h +++ b/Modules/_io/clinic/_iomodule.c.h @@ -139,7 +139,9 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL}; - static _PyArg_Parser _parser = {"O|sizzziO:open", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; + PyObject *argsbuf[8]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *file; const char *mode = "r"; int buffering = -1; @@ -149,13 +151,134 @@ _io_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw int closefd = 1; PyObject *opener = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 8, 0, argsbuf); + if (!args) { goto exit; } + file = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("open", 2, "str", args[1]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(args[1], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + buffering = _PyLong_AsInt(args[2]); + if (buffering == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + if (args[3] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(args[3])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[3], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("open", 4, "str or None", args[3]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + if (args[4] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[4])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[4], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("open", 5, "str or None", args[4]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[5]) { + if (args[5] == Py_None) { + newline = NULL; + } + else if (PyUnicode_Check(args[5])) { + Py_ssize_t newline_length; + newline = PyUnicode_AsUTF8AndSize(args[5], &newline_length); + if (newline == NULL) { + goto exit; + } + if (strlen(newline) != (size_t)newline_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("open", 6, "str or None", args[5]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[6]) { + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + closefd = _PyLong_AsInt(args[6]); + if (closefd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + opener = args[7]; +skip_optional_pos: return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener); exit: return return_value; } -/*[clinic end generated code: output=a2c1af38d943ccec input=a9049054013a1b77]*/ +/*[clinic end generated code: output=19fc9b69a5166f63 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h index 60a6dac..d5e8c8a 100644 --- a/Modules/_io/clinic/bufferedio.c.h +++ b/Modules/_io/clinic/bufferedio.c.h @@ -418,14 +418,40 @@ _io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"raw", "buffer_size", NULL}; - static _PyArg_Parser _parser = {"O|n:BufferedReader", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "BufferedReader", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *raw; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &raw, &buffer_size)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + raw = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional_pos: return_value = _io_BufferedReader___init___impl((buffered *)self, raw, buffer_size); exit: @@ -451,14 +477,40 @@ _io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"raw", "buffer_size", NULL}; - static _PyArg_Parser _parser = {"O|n:BufferedWriter", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "BufferedWriter", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *raw; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &raw, &buffer_size)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + raw = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional_pos: return_value = _io_BufferedWriter___init___impl((buffered *)self, raw, buffer_size); exit: @@ -581,17 +633,43 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"raw", "buffer_size", NULL}; - static _PyArg_Parser _parser = {"O|n:BufferedRandom", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "BufferedRandom", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *raw; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &raw, &buffer_size)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + raw = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + buffer_size = ival; + } +skip_optional_pos: return_value = _io_BufferedRandom___init___impl((buffered *)self, raw, buffer_size); exit: return return_value; } -/*[clinic end generated code: output=b7f51040defff318 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b22b4aedd53c340a input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h index 54c5123..8dd68f5 100644 --- a/Modules/_io/clinic/bytesio.c.h +++ b/Modules/_io/clinic/bytesio.c.h @@ -494,16 +494,25 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"initial_bytes", NULL}; - static _PyArg_Parser _parser = {"|O:BytesIO", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "BytesIO", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *initvalue = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &initvalue)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + initvalue = fastargs[0]; +skip_optional_pos: return_value = _io_BytesIO___init___impl((bytesio *)self, initvalue); exit: return return_value; } -/*[clinic end generated code: output=a6b47dd7921abfcd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=22e8fb54874b6ee5 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h index e7d49d4..8016e98 100644 --- a/Modules/_io/clinic/fileio.c.h +++ b/Modules/_io/clinic/fileio.c.h @@ -50,16 +50,58 @@ _io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL}; - static _PyArg_Parser _parser = {"O|siO:FileIO", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "FileIO", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *nameobj; const char *mode = "r"; int closefd = 1; PyObject *opener = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &nameobj, &mode, &closefd, &opener)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); + if (!fastargs) { goto exit; } + nameobj = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + if (!PyUnicode_Check(fastargs[1])) { + _PyArg_BadArgument("FileIO", 2, "str", fastargs[1]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + if (PyFloat_Check(fastargs[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + closefd = _PyLong_AsInt(fastargs[2]); + if (closefd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + opener = fastargs[3]; +skip_optional_pos: return_value = _io_FileIO___init___impl((fileio *)self, nameobj, mode, closefd, opener); exit: @@ -405,4 +447,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=b6f327457938d4dd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7ee4f3ae584fc6d2 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h index 1757d83..77a720c 100644 --- a/Modules/_io/clinic/stringio.c.h +++ b/Modules/_io/clinic/stringio.c.h @@ -266,14 +266,29 @@ _io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"initial_value", "newline", NULL}; - static _PyArg_Parser _parser = {"|OO:StringIO", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "StringIO", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *value = NULL; PyObject *newline_obj = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &value, &newline_obj)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + value = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + newline_obj = fastargs[1]; +skip_optional_pos: return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj); exit: @@ -333,4 +348,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored)) { return _io_StringIO_seekable_impl(self); } -/*[clinic end generated code: output=db5e51dcc4dae8d5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7aad5ab2e64a25b8 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h index 2a13abf..cec9def 100644 --- a/Modules/_io/clinic/textio.c.h +++ b/Modules/_io/clinic/textio.c.h @@ -25,15 +25,34 @@ _io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject { int return_value = -1; static const char * const _keywords[] = {"decoder", "translate", "errors", NULL}; - static _PyArg_Parser _parser = {"Oi|O:IncrementalNewlineDecoder", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "IncrementalNewlineDecoder", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; PyObject *decoder; int translate; PyObject *errors = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &decoder, &translate, &errors)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 3, 0, argsbuf); + if (!fastargs) { goto exit; } + decoder = fastargs[0]; + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + translate = _PyLong_AsInt(fastargs[1]); + if (translate == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + errors = fastargs[2]; +skip_optional_pos: return_value = _io_IncrementalNewlineDecoder___init___impl((nldecoder_object *)self, decoder, translate, errors); exit: @@ -57,14 +76,30 @@ _io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *const *ar { PyObject *return_value = NULL; static const char * const _keywords[] = {"input", "final", NULL}; - static _PyArg_Parser _parser = {"O|i:decode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *input; int final = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &input, &final)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + input = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + final = _PyLong_AsInt(args[1]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = _io_IncrementalNewlineDecoder_decode_impl(self, input, final); exit: @@ -158,7 +193,11 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL}; - static _PyArg_Parser _parser = {"O|zOzii:TextIOWrapper", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "TextIOWrapper", 0}; + PyObject *argsbuf[6]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *buffer; const char *encoding = NULL; PyObject *errors = Py_None; @@ -166,10 +205,90 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs) int line_buffering = 0; int write_through = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 6, 0, argsbuf); + if (!fastargs) { goto exit; } + buffer = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + if (fastargs[1] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(fastargs[1])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("TextIOWrapper", 2, "str or None", fastargs[1]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + errors = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[3]) { + if (fastargs[3] == Py_None) { + newline = NULL; + } + else if (PyUnicode_Check(fastargs[3])) { + Py_ssize_t newline_length; + newline = PyUnicode_AsUTF8AndSize(fastargs[3], &newline_length); + if (newline == NULL) { + goto exit; + } + if (strlen(newline) != (size_t)newline_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("TextIOWrapper", 4, "str or None", fastargs[3]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[4]) { + if (PyFloat_Check(fastargs[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + line_buffering = _PyLong_AsInt(fastargs[4]); + if (line_buffering == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(fastargs[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + write_through = _PyLong_AsInt(fastargs[5]); + if (write_through == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = _io_TextIOWrapper___init___impl((textio *)self, buffer, encoding, errors, newline, line_buffering, write_through); exit: @@ -199,17 +318,48 @@ _io_TextIOWrapper_reconfigure(textio *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", "newline", "line_buffering", "write_through", NULL}; - static _PyArg_Parser _parser = {"|$OOOOO:reconfigure", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "reconfigure", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *encoding = Py_None; PyObject *errors = Py_None; PyObject *newline_obj = NULL; PyObject *line_buffering_obj = Py_None; PyObject *write_through_obj = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &encoding, &errors, &newline_obj, &line_buffering_obj, &write_through_obj)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + encoding = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[1]) { + errors = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + newline_obj = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + line_buffering_obj = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + write_through_obj = args[4]; +skip_optional_kwonly: return_value = _io_TextIOWrapper_reconfigure_impl(self, encoding, errors, newline_obj, line_buffering_obj, write_through_obj); exit: @@ -551,4 +701,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored)) { return _io_TextIOWrapper_close_impl(self); } -/*[clinic end generated code: output=c3d1b2a5d2d2d429 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b651e056e3000f88 input=a9049054013a1b77]*/ diff --git a/Modules/_io/clinic/winconsoleio.c.h b/Modules/_io/clinic/winconsoleio.c.h index e7cd854..bb0cdc4 100644 --- a/Modules/_io/clinic/winconsoleio.c.h +++ b/Modules/_io/clinic/winconsoleio.c.h @@ -49,16 +49,58 @@ _io__WindowsConsoleIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL}; - static _PyArg_Parser _parser = {"O|siO:_WindowsConsoleIO", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_WindowsConsoleIO", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *nameobj; const char *mode = "r"; int closefd = 1; PyObject *opener = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &nameobj, &mode, &closefd, &opener)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 4, 0, argsbuf); + if (!fastargs) { goto exit; } + nameobj = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + if (!PyUnicode_Check(fastargs[1])) { + _PyArg_BadArgument("_WindowsConsoleIO", 2, "str", fastargs[1]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(fastargs[1], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + if (PyFloat_Check(fastargs[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + closefd = _PyLong_AsInt(fastargs[2]); + if (closefd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + opener = fastargs[3]; +skip_optional_pos: return_value = _io__WindowsConsoleIO___init___impl((winconsoleio *)self, nameobj, mode, closefd, opener); exit: @@ -344,4 +386,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=ab0f0ee8062eecb3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=57bf2c09a42bd330 input=a9049054013a1b77]*/ diff --git a/Modules/_multiprocessing/clinic/posixshmem.c.h b/Modules/_multiprocessing/clinic/posixshmem.c.h index 20abddc..0ebfa2f 100644 --- a/Modules/_multiprocessing/clinic/posixshmem.c.h +++ b/Modules/_multiprocessing/clinic/posixshmem.c.h @@ -22,16 +22,48 @@ _posixshmem_shm_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", "mode", NULL}; - static _PyArg_Parser _parser = {"Ui|i:shm_open", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "shm_open", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *path; int flags; int mode = 511; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path, &flags, &mode)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { goto exit; } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("shm_open", 1, "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + path = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[2]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: _return_value = _posixshmem_shm_open_impl(module, path, flags, mode); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -67,13 +99,22 @@ _posixshmem_shm_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"U:shm_unlink", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "shm_unlink", 0}; + PyObject *argsbuf[1]; PyObject *path; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("shm_unlink", 1, "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { goto exit; } + path = args[0]; return_value = _posixshmem_shm_unlink_impl(module, path); exit: @@ -89,4 +130,4 @@ exit: #ifndef _POSIXSHMEM_SHM_UNLINK_METHODDEF #define _POSIXSHMEM_SHM_UNLINK_METHODDEF #endif /* !defined(_POSIXSHMEM_SHM_UNLINK_METHODDEF) */ -/*[clinic end generated code: output=ff9cf0bc9b8baddf input=a9049054013a1b77]*/ +/*[clinic end generated code: output=be42e23c18677c0f input=a9049054013a1b77]*/ diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h index c62a641..84774f0 100644 --- a/Modules/cjkcodecs/clinic/multibytecodec.c.h +++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h @@ -26,14 +26,39 @@ _multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *cons { PyObject *return_value = NULL; static const char * const _keywords[] = {"input", "errors", NULL}; - static _PyArg_Parser _parser = {"O|z:encode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *input; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &input, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + input = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("encode", 2, "str or None", args[1]); + goto exit; + } +skip_optional_pos: return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors); exit: @@ -64,14 +89,45 @@ _multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *cons { PyObject *return_value = NULL; static const char * const _keywords[] = {"input", "errors", NULL}; - static _PyArg_Parser _parser = {"y*|z:decode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer input = {NULL, NULL}; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &input, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&input, 'C')) { + _PyArg_BadArgument("decode", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1] == Py_None) { + errors = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("decode", 2, "str or None", args[1]); goto exit; } +skip_optional_pos: return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors); exit: @@ -101,14 +157,30 @@ _multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"input", "final", NULL}; - static _PyArg_Parser _parser = {"O|i:encode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *input; int final = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &input, &final)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + input = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[1]); + if (final == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final); exit: @@ -196,14 +268,36 @@ _multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"input", "final", NULL}; - static _PyArg_Parser _parser = {"y*|i:decode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer input = {NULL, NULL}; int final = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &input, &final)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&input, 'C')) { + _PyArg_BadArgument("decode", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + final = _PyLong_AsInt(args[1]); + if (final == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final); exit: @@ -431,4 +525,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=bcd6311010557faf input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eb95a408c4ddbfff input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_asynciomodule.c.h b/Modules/clinic/_asynciomodule.c.h index 860b57f..87669f7 100644 --- a/Modules/clinic/_asynciomodule.c.h +++ b/Modules/clinic/_asynciomodule.c.h @@ -27,13 +27,22 @@ _asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"loop", NULL}; - static _PyArg_Parser _parser = {"|$O:Future", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Future", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *loop = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &loop)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + loop = fastargs[0]; +skip_optional_kwonly: return_value = _asyncio_Future___init___impl((FutureObj *)self, loop); exit: @@ -131,14 +140,22 @@ _asyncio_Future_add_done_callback(FutureObj *self, PyObject *const *args, Py_ssi { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "context", NULL}; - static _PyArg_Parser _parser = {"O|$O:add_done_callback", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "add_done_callback", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *fn; PyObject *context = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fn, &context)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + fn = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + context = args[1]; +skip_optional_kwonly: return_value = _asyncio_Future_add_done_callback_impl(self, fn, context); exit: @@ -267,15 +284,31 @@ _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"coro", "loop", "name", NULL}; - static _PyArg_Parser _parser = {"O|$OO:Task", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Task", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *coro; PyObject *loop = Py_None; PyObject *name = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &coro, &loop, &name)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + coro = fastargs[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + loop = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + name = fastargs[2]; +skip_optional_kwonly: return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name); exit: @@ -303,13 +336,20 @@ _asyncio_Task_current_task(PyTypeObject *type, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"loop", NULL}; - static _PyArg_Parser _parser = {"|O:current_task", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "current_task", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *loop = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &loop)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + loop = args[0]; +skip_optional_pos: return_value = _asyncio_Task_current_task_impl(type, loop); exit: @@ -335,13 +375,20 @@ _asyncio_Task_all_tasks(PyTypeObject *type, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"loop", NULL}; - static _PyArg_Parser _parser = {"|O:all_tasks", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "all_tasks", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *loop = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &loop)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + loop = args[0]; +skip_optional_pos: return_value = _asyncio_Task_all_tasks_impl(type, loop); exit: @@ -435,13 +482,20 @@ _asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"limit", NULL}; - static _PyArg_Parser _parser = {"|$O:get_stack", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get_stack", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *limit = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &limit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + limit = args[0]; +skip_optional_kwonly: return_value = _asyncio_Task_get_stack_impl(self, limit); exit: @@ -472,14 +526,27 @@ _asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"limit", "file", NULL}; - static _PyArg_Parser _parser = {"|$OO:print_stack", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "print_stack", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *limit = Py_None; PyObject *file = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &limit, &file)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + limit = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + file = args[1]; +skip_optional_kwonly: return_value = _asyncio_Task_print_stack_impl(self, limit, file); exit: @@ -624,13 +691,15 @@ _asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"task", NULL}; - static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_register_task", 0}; + PyObject *argsbuf[1]; PyObject *task; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &task)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + task = args[0]; return_value = _asyncio__register_task_impl(module, task); exit: @@ -656,13 +725,15 @@ _asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"task", NULL}; - static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_unregister_task", 0}; + PyObject *argsbuf[1]; PyObject *task; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &task)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + task = args[0]; return_value = _asyncio__unregister_task_impl(module, task); exit: @@ -690,14 +761,17 @@ _asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"loop", "task", NULL}; - static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_enter_task", 0}; + PyObject *argsbuf[2]; PyObject *loop; PyObject *task; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &loop, &task)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + loop = args[0]; + task = args[1]; return_value = _asyncio__enter_task_impl(module, loop, task); exit: @@ -725,17 +799,20 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"loop", "task", NULL}; - static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_leave_task", 0}; + PyObject *argsbuf[2]; PyObject *loop; PyObject *task; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &loop, &task)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + loop = args[0]; + task = args[1]; return_value = _asyncio__leave_task_impl(module, loop, task); exit: return return_value; } -/*[clinic end generated code: output=fd474bdc8f03d5ae input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e3b02d96da56e80c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_bz2module.c.h b/Modules/clinic/_bz2module.c.h index fb64333..cc16d8b 100644 --- a/Modules/clinic/_bz2module.c.h +++ b/Modules/clinic/_bz2module.c.h @@ -142,14 +142,44 @@ _bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject *const *args, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "max_length", NULL}; - static _PyArg_Parser _parser = {"y*|n:decompress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &max_length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + max_length = ival; + } +skip_optional_pos: return_value = _bz2_BZ2Decompressor_decompress_impl(self, &data, max_length); exit: @@ -190,4 +220,4 @@ _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=892c6133e97ff840 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8e123f4eec497655 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_codecsmodule.c.h b/Modules/clinic/_codecsmodule.c.h index a8223ad..d1f4cf3 100644 --- a/Modules/clinic/_codecsmodule.c.h +++ b/Modules/clinic/_codecsmodule.c.h @@ -76,15 +76,53 @@ _codecs_encode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"obj", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"O|ss:encode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *obj; const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &obj, &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("encode", 2, "str", args[1]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("encode", 3, "str", args[2]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = _codecs_encode_impl(module, obj, encoding, errors); exit: @@ -115,15 +153,53 @@ _codecs_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"obj", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"O|ss:decode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *obj; const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &obj, &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("decode", 2, "str", args[1]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("decode", 3, "str", args[2]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[2], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } +skip_optional_pos: return_value = _codecs_decode_impl(module, obj, encoding, errors); exit: @@ -2948,4 +3024,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=85ea29db163ee74c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=02bd0f0cf9a28150 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h index 659fd4e..6837eac 100644 --- a/Modules/clinic/_cursesmodule.c.h +++ b/Modules/clinic/_cursesmodule.c.h @@ -2988,14 +2988,52 @@ _curses_setupterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO { PyObject *return_value = NULL; static const char * const _keywords[] = {"term", "fd", NULL}; - static _PyArg_Parser _parser = {"|zi:setupterm", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "setupterm", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *term = NULL; int fd = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &term, &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (args[0] == Py_None) { + term = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t term_length; + term = PyUnicode_AsUTF8AndSize(args[0], &term_length); + if (term == NULL) { + goto exit; + } + if (strlen(term) != (size_t)term_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("setupterm", 1, "str or None", args[0]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[1]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = _curses_setupterm_impl(module, term, fd); exit: @@ -4531,4 +4569,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=5305982cb312a911 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1350eeb0c1e06af6 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_datetimemodule.c.h b/Modules/clinic/_datetimemodule.c.h index 36b4fca..447036c 100644 --- a/Modules/clinic/_datetimemodule.c.h +++ b/Modules/clinic/_datetimemodule.c.h @@ -36,16 +36,23 @@ datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"tz", NULL}; - static _PyArg_Parser _parser = {"|O:now", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "now", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *tz = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &tz)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + tz = args[0]; +skip_optional_pos: return_value = datetime_datetime_now_impl(type, tz); exit: return return_value; } -/*[clinic end generated code: output=b3d746843403a8ce input=a9049054013a1b77]*/ +/*[clinic end generated code: output=aae916ab728ca85b input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_elementtree.c.h b/Modules/clinic/_elementtree.c.h index 1293acd..d239c80 100644 --- a/Modules/clinic/_elementtree.c.h +++ b/Modules/clinic/_elementtree.c.h @@ -169,14 +169,22 @@ _elementtree_Element_find(ElementObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "namespaces", NULL}; - static _PyArg_Parser _parser = {"O|O:find", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "find", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *namespaces = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path, &namespaces)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + namespaces = args[1]; +skip_optional_pos: return_value = _elementtree_Element_find_impl(self, path, namespaces); exit: @@ -201,15 +209,29 @@ _elementtree_Element_findtext(ElementObject *self, PyObject *const *args, Py_ssi { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "default", "namespaces", NULL}; - static _PyArg_Parser _parser = {"O|OO:findtext", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "findtext", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *default_value = Py_None; PyObject *namespaces = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path, &default_value, &namespaces)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + default_value = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + namespaces = args[2]; +skip_optional_pos: return_value = _elementtree_Element_findtext_impl(self, path, default_value, namespaces); exit: @@ -233,14 +255,22 @@ _elementtree_Element_findall(ElementObject *self, PyObject *const *args, Py_ssiz { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "namespaces", NULL}; - static _PyArg_Parser _parser = {"O|O:findall", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *namespaces = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path, &namespaces)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + namespaces = args[1]; +skip_optional_pos: return_value = _elementtree_Element_findall_impl(self, path, namespaces); exit: @@ -264,14 +294,22 @@ _elementtree_Element_iterfind(ElementObject *self, PyObject *const *args, Py_ssi { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "namespaces", NULL}; - static _PyArg_Parser _parser = {"O|O:iterfind", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "iterfind", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *path; PyObject *namespaces = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path, &namespaces)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + path = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + namespaces = args[1]; +skip_optional_pos: return_value = _elementtree_Element_iterfind_impl(self, path, namespaces); exit: @@ -295,14 +333,22 @@ _elementtree_Element_get(ElementObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "default", NULL}; - static _PyArg_Parser _parser = {"O|O:get", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *key; PyObject *default_value = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &key, &default_value)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + key = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[1]; +skip_optional_pos: return_value = _elementtree_Element_get_impl(self, key, default_value); exit: @@ -342,13 +388,20 @@ _elementtree_Element_iter(ElementObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"tag", NULL}; - static _PyArg_Parser _parser = {"|O:iter", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "iter", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *tag = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &tag)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + tag = args[0]; +skip_optional_pos: return_value = _elementtree_Element_iter_impl(self, tag); exit: @@ -371,13 +424,20 @@ _elementtree_Element_getiterator(ElementObject *self, PyObject *const *args, Py_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"tag", NULL}; - static _PyArg_Parser _parser = {"|O:getiterator", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "getiterator", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *tag = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &tag)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + tag = args[0]; +skip_optional_pos: return_value = _elementtree_Element_getiterator_impl(self, tag); exit: @@ -582,13 +642,22 @@ _elementtree_TreeBuilder___init__(PyObject *self, PyObject *args, PyObject *kwar { int return_value = -1; static const char * const _keywords[] = {"element_factory", NULL}; - static _PyArg_Parser _parser = {"|O:TreeBuilder", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "TreeBuilder", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *element_factory = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &element_factory)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + element_factory = fastargs[0]; +skip_optional_pos: return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory); exit: @@ -671,14 +740,46 @@ _elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs { int return_value = -1; static const char * const _keywords[] = {"target", "encoding", NULL}; - static _PyArg_Parser _parser = {"|$Oz:XMLParser", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "XMLParser", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *target = NULL; const char *encoding = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &target, &encoding)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[0]) { + target = fastargs[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[1] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(fastargs[1])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("XMLParser", 2, "str or None", fastargs[1]); goto exit; } +skip_optional_kwonly: return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, target, encoding); exit: @@ -752,4 +853,4 @@ skip_optional: exit: return return_value; } -/*[clinic end generated code: output=0c15c41e03a7829f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=440b5d90a4b86590 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h index 43f9651..5596f13 100644 --- a/Modules/clinic/_hashopenssl.c.h +++ b/Modules/clinic/_hashopenssl.c.h @@ -87,14 +87,22 @@ EVP_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"name", "string", NULL}; - static _PyArg_Parser _parser = {"O|O:new", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "new", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *name_obj; PyObject *data_obj = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &name_obj, &data_obj)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + name_obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + data_obj = args[1]; +skip_optional_pos: return_value = EVP_new_impl(module, name_obj, data_obj); exit: @@ -123,17 +131,60 @@ pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"hash_name", "password", "salt", "iterations", "dklen", NULL}; - static _PyArg_Parser _parser = {"sy*y*l|O:pbkdf2_hmac", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "pbkdf2_hmac", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; const char *hash_name; Py_buffer password = {NULL, NULL}; Py_buffer salt = {NULL, NULL}; long iterations; PyObject *dklen_obj = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &hash_name, &password, &salt, &iterations, &dklen_obj)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 5, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("pbkdf2_hmac", 1, "str", args[0]); + goto exit; + } + Py_ssize_t hash_name_length; + hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length); + if (hash_name == NULL) { + goto exit; + } + if (strlen(hash_name) != (size_t)hash_name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&password, 'C')) { + _PyArg_BadArgument("pbkdf2_hmac", 2, "contiguous buffer", args[1]); + goto exit; + } + if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&salt, 'C')) { + _PyArg_BadArgument("pbkdf2_hmac", 3, "contiguous buffer", args[2]); + goto exit; + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + iterations = PyLong_AsLong(args[3]); + if (iterations == -1 && PyErr_Occurred()) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + dklen_obj = args[4]; +skip_optional_pos: return_value = pbkdf2_hmac_impl(module, hash_name, &password, &salt, iterations, dklen_obj); exit: @@ -173,7 +224,9 @@ _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"password", "salt", "n", "r", "p", "maxmem", "dklen", NULL}; - static _PyArg_Parser _parser = {"y*|$y*O!O!O!ll:scrypt", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "scrypt", 0}; + PyObject *argsbuf[7]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer password = {NULL, NULL}; Py_buffer salt = {NULL, NULL}; PyObject *n_obj = Py_None; @@ -182,10 +235,86 @@ _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj long maxmem = 0; long dklen = 64; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &password, &salt, &PyLong_Type, &n_obj, &PyLong_Type, &r_obj, &PyLong_Type, &p_obj, &maxmem, &dklen)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&password, 'C')) { + _PyArg_BadArgument("scrypt", 1, "contiguous buffer", args[0]); goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&salt, 'C')) { + _PyArg_BadArgument("scrypt", 2, "contiguous buffer", args[1]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (!PyLong_Check(args[2])) { + _PyArg_BadArgument("scrypt", 3, "int", args[2]); + goto exit; + } + n_obj = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!PyLong_Check(args[3])) { + _PyArg_BadArgument("scrypt", 4, "int", args[3]); + goto exit; + } + r_obj = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + if (!PyLong_Check(args[4])) { + _PyArg_BadArgument("scrypt", 5, "int", args[4]); + goto exit; + } + p_obj = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + maxmem = PyLong_AsLong(args[5]); + if (maxmem == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + dklen = PyLong_AsLong(args[6]); + if (dklen == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = _hashlib_scrypt_impl(module, &password, &salt, n_obj, r_obj, p_obj, maxmem, dklen); exit: @@ -221,13 +350,41 @@ _hashlib_hmac_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "msg", "digest", NULL}; - static _PyArg_Parser _parser = {"y*y*s:hmac_digest", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "hmac_digest", 0}; + PyObject *argsbuf[3]; Py_buffer key = {NULL, NULL}; Py_buffer msg = {NULL, NULL}; const char *digest; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &key, &msg, &digest)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&key, 'C')) { + _PyArg_BadArgument("hmac_digest", 1, "contiguous buffer", args[0]); + goto exit; + } + if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&msg, 'C')) { + _PyArg_BadArgument("hmac_digest", 2, "contiguous buffer", args[1]); + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("hmac_digest", 3, "str", args[2]); + goto exit; + } + Py_ssize_t digest_length; + digest = PyUnicode_AsUTF8AndSize(args[2], &digest_length); + if (digest == NULL) { + goto exit; + } + if (strlen(digest) != (size_t)digest_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } return_value = _hashlib_hmac_digest_impl(module, &key, &msg, digest); @@ -252,4 +409,4 @@ exit: #ifndef _HASHLIB_SCRYPT_METHODDEF #define _HASHLIB_SCRYPT_METHODDEF #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */ -/*[clinic end generated code: output=fe5931d2b301ca12 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5955ec791260045a input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_lzmamodule.c.h b/Modules/clinic/_lzmamodule.c.h index aeb98a6..68aa770 100644 --- a/Modules/clinic/_lzmamodule.c.h +++ b/Modules/clinic/_lzmamodule.c.h @@ -96,14 +96,44 @@ _lzma_LZMADecompressor_decompress(Decompressor *self, PyObject *const *args, Py_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "max_length", NULL}; - static _PyArg_Parser _parser = {"y*|n:decompress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &max_length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + max_length = ival; + } +skip_optional_pos: return_value = _lzma_LZMADecompressor_decompress_impl(self, &data, max_length); exit: @@ -147,15 +177,44 @@ _lzma_LZMADecompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs { int return_value = -1; static const char * const _keywords[] = {"format", "memlimit", "filters", NULL}; - static _PyArg_Parser _parser = {"|iOO:LZMADecompressor", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "LZMADecompressor", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; int format = FORMAT_AUTO; PyObject *memlimit = Py_None; PyObject *filters = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &format, &memlimit, &filters)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 3, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + if (PyFloat_Check(fastargs[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + format = _PyLong_AsInt(fastargs[0]); + if (format == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[1]) { + memlimit = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + filters = fastargs[2]; +skip_optional_pos: return_value = _lzma_LZMADecompressor___init___impl((Decompressor *)self, format, memlimit, filters); exit: @@ -275,4 +334,4 @@ exit: return return_value; } -/*[clinic end generated code: output=47e4732df79509ad input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1a290aa478603107 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_opcode.c.h b/Modules/clinic/_opcode.c.h index 2104a52..777701f 100644 --- a/Modules/clinic/_opcode.c.h +++ b/Modules/clinic/_opcode.c.h @@ -20,16 +20,38 @@ _opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "", "jump", NULL}; - static _PyArg_Parser _parser = {"i|O$O:stack_effect", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "stack_effect", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; int opcode; PyObject *oparg = Py_None; PyObject *jump = Py_None; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &opcode, &oparg, &jump)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + opcode = _PyLong_AsInt(args[0]); + if (opcode == -1 && PyErr_Occurred()) { + goto exit; + } + if (nargs < 2) { + goto skip_optional_posonly; + } + noptargs--; + oparg = args[1]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_kwonly; + } + jump = args[2]; +skip_optional_kwonly: _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -39,4 +61,4 @@ _opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=871941eea3d855c6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7bc08f2835b2cf89 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_pickle.c.h b/Modules/clinic/_pickle.c.h index 2759b2f2..1da2f93 100644 --- a/Modules/clinic/_pickle.c.h +++ b/Modules/clinic/_pickle.c.h @@ -94,15 +94,34 @@ _pickle_Pickler___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"file", "protocol", "fix_imports", NULL}; - static _PyArg_Parser _parser = {"O|Op:Pickler", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Pickler", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *file; PyObject *protocol = NULL; int fix_imports = 1; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &file, &protocol, &fix_imports)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 3, 0, argsbuf); + if (!fastargs) { goto exit; } + file = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + protocol = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + fix_imports = PyObject_IsTrue(fastargs[2]); + if (fix_imports < 0) { + goto exit; + } +skip_optional_pos: return_value = _pickle_Pickler___init___impl((PicklerObject *)self, file, protocol, fix_imports); exit: @@ -287,16 +306,65 @@ _pickle_Unpickler___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"O|$pss:Unpickler", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Unpickler", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *file; int fix_imports = 1; const char *encoding = "ASCII"; const char *errors = "strict"; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &file, &fix_imports, &encoding, &errors)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + file = fastargs[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + fix_imports = PyObject_IsTrue(fastargs[1]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + if (!PyUnicode_Check(fastargs[2])) { + _PyArg_BadArgument("Unpickler", 3, "str", fastargs[2]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!PyUnicode_Check(fastargs[3])) { + _PyArg_BadArgument("Unpickler", 4, "str", fastargs[3]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(fastargs[3], &errors_length); + if (errors == NULL) { goto exit; } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_kwonly: return_value = _pickle_Unpickler___init___impl((UnpicklerObject *)self, file, fix_imports, encoding, errors); exit: @@ -396,16 +464,38 @@ _pickle_dump(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"obj", "file", "protocol", "fix_imports", NULL}; - static _PyArg_Parser _parser = {"OO|O$p:dump", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "dump", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *obj; PyObject *file; PyObject *protocol = NULL; int fix_imports = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &obj, &file, &protocol, &fix_imports)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + obj = args[0]; + file = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + protocol = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + fix_imports = PyObject_IsTrue(args[3]); + if (fix_imports < 0) { goto exit; } +skip_optional_kwonly: return_value = _pickle_dump_impl(module, obj, file, protocol, fix_imports); exit: @@ -443,15 +533,36 @@ _pickle_dumps(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"obj", "protocol", "fix_imports", NULL}; - static _PyArg_Parser _parser = {"O|O$p:dumps", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "dumps", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *obj; PyObject *protocol = NULL; int fix_imports = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &obj, &protocol, &fix_imports)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + obj = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + protocol = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + fix_imports = PyObject_IsTrue(args[2]); + if (fix_imports < 0) { + goto exit; + } +skip_optional_kwonly: return_value = _pickle_dumps_impl(module, obj, protocol, fix_imports); exit: @@ -499,16 +610,63 @@ _pickle_load(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"file", "fix_imports", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"O|$pss:load", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "load", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *file; int fix_imports = 1; const char *encoding = "ASCII"; const char *errors = "strict"; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &file, &fix_imports, &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + file = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + fix_imports = PyObject_IsTrue(args[1]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("load", 3, "str", args[2]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!PyUnicode_Check(args[3])) { + _PyArg_BadArgument("load", 4, "str", args[3]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } +skip_optional_kwonly: return_value = _pickle_load_impl(module, file, fix_imports, encoding, errors); exit: @@ -547,19 +705,66 @@ _pickle_loads(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "fix_imports", "encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"O|$pss:loads", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "loads", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *data; int fix_imports = 1; const char *encoding = "ASCII"; const char *errors = "strict"; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &fix_imports, &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + data = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + fix_imports = PyObject_IsTrue(args[1]); + if (fix_imports < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[2]) { + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("loads", 3, "str", args[2]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[2], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!PyUnicode_Check(args[3])) { + _PyArg_BadArgument("loads", 4, "str", args[3]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[3], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } +skip_optional_kwonly: return_value = _pickle_loads_impl(module, data, fix_imports, encoding, errors); exit: return return_value; } -/*[clinic end generated code: output=225f06abcf27ed2b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8f972562c8f71e2b input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_queuemodule.c.h b/Modules/clinic/_queuemodule.c.h index a19fe78..c25eacf 100644 --- a/Modules/clinic/_queuemodule.c.h +++ b/Modules/clinic/_queuemodule.c.h @@ -51,15 +51,32 @@ _queue_SimpleQueue_put(simplequeueobject *self, PyObject *const *args, Py_ssize_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"item", "block", "timeout", NULL}; - static _PyArg_Parser _parser = {"O|pO:put", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "put", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *item; int block = 1; PyObject *timeout = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &item, &block, &timeout)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + item = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + block = PyObject_IsTrue(args[1]); + if (block < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + timeout = args[2]; +skip_optional_pos: return_value = _queue_SimpleQueue_put_impl(self, item, block, timeout); exit: @@ -86,13 +103,15 @@ _queue_SimpleQueue_put_nowait(simplequeueobject *self, PyObject *const *args, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"item", NULL}; - static _PyArg_Parser _parser = {"O:put_nowait", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "put_nowait", 0}; + PyObject *argsbuf[1]; PyObject *item; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &item)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + item = args[0]; return_value = _queue_SimpleQueue_put_nowait_impl(self, item); exit: @@ -125,14 +144,30 @@ _queue_SimpleQueue_get(simplequeueobject *self, PyObject *const *args, Py_ssize_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"block", "timeout", NULL}; - static _PyArg_Parser _parser = {"|pO:get", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int block = 1; PyObject *timeout = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &block, &timeout)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + block = PyObject_IsTrue(args[0]); + if (block < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + timeout = args[1]; +skip_optional_pos: return_value = _queue_SimpleQueue_get_impl(self, block, timeout); exit: @@ -215,4 +250,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=c12ce9050f153304 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b4717e2974cbc909 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h index e5bb32f..9c08dec 100644 --- a/Modules/clinic/_sre.c.h +++ b/Modules/clinic/_sre.c.h @@ -195,15 +195,61 @@ _sre_SRE_Pattern_match(PatternObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:match", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "match", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos); exit: @@ -228,15 +274,61 @@ _sre_SRE_Pattern_fullmatch(PatternObject *self, PyObject *const *args, Py_ssize_ { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:fullmatch", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos); exit: @@ -263,15 +355,61 @@ _sre_SRE_Pattern_search(PatternObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:search", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "search", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos); exit: @@ -296,15 +434,61 @@ _sre_SRE_Pattern_findall(PatternObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:findall", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos); exit: @@ -331,15 +515,61 @@ _sre_SRE_Pattern_finditer(PatternObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:finditer", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_finditer_impl(self, string, pos, endpos); exit: @@ -363,15 +593,61 @@ _sre_SRE_Pattern_scanner(PatternObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; - static _PyArg_Parser _parser = {"O|nn:scanner", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t pos = 0; Py_ssize_t endpos = PY_SSIZE_T_MAX; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &pos, &endpos)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + pos = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + endpos = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_scanner_impl(self, string, pos, endpos); exit: @@ -396,14 +672,38 @@ _sre_SRE_Pattern_split(PatternObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"O|n:split", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *string; Py_ssize_t maxsplit = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + string = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit); exit: @@ -428,15 +728,40 @@ _sre_SRE_Pattern_sub(PatternObject *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"repl", "string", "count", NULL}; - static _PyArg_Parser _parser = {"OO|n:sub", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *repl; PyObject *string; Py_ssize_t count = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &repl, &string, &count)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + repl = args[0]; + string = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_sub_impl(self, repl, string, count); exit: @@ -461,15 +786,40 @@ _sre_SRE_Pattern_subn(PatternObject *self, PyObject *const *args, Py_ssize_t nar { PyObject *return_value = NULL; static const char * const _keywords[] = {"repl", "string", "count", NULL}; - static _PyArg_Parser _parser = {"OO|n:subn", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *repl; PyObject *string; Py_ssize_t count = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &repl, &string, &count)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + repl = args[0]; + string = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + count = ival; + } +skip_optional_pos: return_value = _sre_SRE_Pattern_subn_impl(self, repl, string, count); exit: @@ -520,7 +870,8 @@ _sre_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL}; - static _PyArg_Parser _parser = {"OiO!nO!O!:compile", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "compile", 0}; + PyObject *argsbuf[6]; PyObject *pattern; int flags; PyObject *code; @@ -528,10 +879,52 @@ _sre_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject PyObject *groupindex; PyObject *indexgroup; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &pattern, &flags, &PyList_Type, &code, &groups, &PyDict_Type, &groupindex, &PyTuple_Type, &indexgroup)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 6, 6, 0, argsbuf); + if (!args) { goto exit; } + pattern = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!PyList_Check(args[2])) { + _PyArg_BadArgument("compile", 3, "list", args[2]); + goto exit; + } + code = args[2]; + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[3]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + groups = ival; + } + if (!PyDict_Check(args[4])) { + _PyArg_BadArgument("compile", 5, "dict", args[4]); + goto exit; + } + groupindex = args[4]; + if (!PyTuple_Check(args[5])) { + _PyArg_BadArgument("compile", 6, "tuple", args[5]); + goto exit; + } + indexgroup = args[5]; return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup); exit: @@ -555,13 +948,15 @@ _sre_SRE_Match_expand(MatchObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"template", NULL}; - static _PyArg_Parser _parser = {"O:expand", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "expand", 0}; + PyObject *argsbuf[1]; PyObject *template; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &template)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + template = args[0]; return_value = _sre_SRE_Match_expand_impl(self, template); exit: @@ -588,13 +983,20 @@ _sre_SRE_Match_groups(MatchObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"default", NULL}; - static _PyArg_Parser _parser = {"|O:groups", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "groups", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *default_value = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &default_value)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[0]; +skip_optional_pos: return_value = _sre_SRE_Match_groups_impl(self, default_value); exit: @@ -621,13 +1023,20 @@ _sre_SRE_Match_groupdict(MatchObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"default", NULL}; - static _PyArg_Parser _parser = {"|O:groupdict", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "groupdict", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *default_value = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &default_value)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[0]; +skip_optional_pos: return_value = _sre_SRE_Match_groupdict_impl(self, default_value); exit: @@ -798,4 +1207,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored)) { return _sre_SRE_Scanner_search_impl(self); } -/*[clinic end generated code: output=8d19359d6a4a3a7e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=67b702da5bdc9cac input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_ssl.c.h b/Modules/clinic/_ssl.c.h index 3ec30c3..b1012f7 100644 --- a/Modules/clinic/_ssl.c.h +++ b/Modules/clinic/_ssl.c.h @@ -340,13 +340,32 @@ _ssl__SSLSocket_get_channel_binding(PySSLSocket *self, PyObject *const *args, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"cb_type", NULL}; - static _PyArg_Parser _parser = {"|s:get_channel_binding", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get_channel_binding", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *cb_type = "tls-unique"; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &cb_type)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("get_channel_binding", 1, "str", args[0]); + goto exit; + } + Py_ssize_t cb_type_length; + cb_type = PyUnicode_AsUTF8AndSize(args[0], &cb_type_length); + if (cb_type == NULL) { + goto exit; + } + if (strlen(cb_type) != (size_t)cb_type_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = _ssl__SSLSocket_get_channel_binding_impl(self, cb_type); exit: @@ -548,15 +567,29 @@ _ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject *const *args, Py_s { PyObject *return_value = NULL; static const char * const _keywords[] = {"certfile", "keyfile", "password", NULL}; - static _PyArg_Parser _parser = {"O|OO:load_cert_chain", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "load_cert_chain", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *certfile; PyObject *keyfile = NULL; PyObject *password = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &certfile, &keyfile, &password)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + certfile = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + keyfile = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + password = args[2]; +skip_optional_pos: return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password); exit: @@ -582,15 +615,34 @@ _ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject *const *args { PyObject *return_value = NULL; static const char * const _keywords[] = {"cafile", "capath", "cadata", NULL}; - static _PyArg_Parser _parser = {"|OOO:load_verify_locations", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "load_verify_locations", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *cafile = NULL; PyObject *capath = NULL; PyObject *cadata = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &cafile, &capath, &cadata)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + cafile = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[1]) { + capath = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + cadata = args[2]; +skip_optional_pos: return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata); exit: @@ -624,17 +676,54 @@ _ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject *const *args, Py_ssiz { PyObject *return_value = NULL; static const char * const _keywords[] = {"sock", "server_side", "server_hostname", "owner", "session", NULL}; - static _PyArg_Parser _parser = {"O!i|O$OO:_wrap_socket", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_socket", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *sock; int server_side; PyObject *hostname_obj = Py_None; PyObject *owner = Py_None; PyObject *session = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - PySocketModule.Sock_Type, &sock, &server_side, &hostname_obj, &owner, &session)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyObject_TypeCheck(args[0], PySocketModule.Sock_Type)) { + _PyArg_BadArgument("_wrap_socket", 1, (PySocketModule.Sock_Type)->tp_name, args[0]); goto exit; } + sock = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + server_side = _PyLong_AsInt(args[1]); + if (server_side == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + hostname_obj = args[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + owner = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + session = args[4]; +skip_optional_kwonly: return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj, owner, session); exit: @@ -661,7 +750,9 @@ _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"incoming", "outgoing", "server_side", "server_hostname", "owner", "session", NULL}; - static _PyArg_Parser _parser = {"O!O!i|O$OO:_wrap_bio", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_bio", 0}; + PyObject *argsbuf[6]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; PySSLMemoryBIO *incoming; PySSLMemoryBIO *outgoing; int server_side; @@ -669,10 +760,50 @@ _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t PyObject *owner = Py_None; PyObject *session = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &PySSLMemoryBIO_Type, &incoming, &PySSLMemoryBIO_Type, &outgoing, &server_side, &hostname_obj, &owner, &session)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); + if (!args) { goto exit; } + if (!PyObject_TypeCheck(args[0], &PySSLMemoryBIO_Type)) { + _PyArg_BadArgument("_wrap_bio", 1, (&PySSLMemoryBIO_Type)->tp_name, args[0]); + goto exit; + } + incoming = (PySSLMemoryBIO *)args[0]; + if (!PyObject_TypeCheck(args[1], &PySSLMemoryBIO_Type)) { + _PyArg_BadArgument("_wrap_bio", 2, (&PySSLMemoryBIO_Type)->tp_name, args[1]); + goto exit; + } + outgoing = (PySSLMemoryBIO *)args[1]; + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + server_side = _PyLong_AsInt(args[2]); + if (server_side == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[3]) { + hostname_obj = args[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[4]) { + owner = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + session = args[5]; +skip_optional_kwonly: return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj, owner, session); exit: @@ -772,13 +903,23 @@ _ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject *const *args, Py_ssiz { PyObject *return_value = NULL; static const char * const _keywords[] = {"binary_form", NULL}; - static _PyArg_Parser _parser = {"|p:get_ca_certs", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get_ca_certs", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int binary_form = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &binary_form)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + binary_form = PyObject_IsTrue(args[0]); + if (binary_form < 0) { + goto exit; + } +skip_optional_pos: return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form); exit: @@ -1131,14 +1272,37 @@ _ssl_txt2obj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"txt", "name", NULL}; - static _PyArg_Parser _parser = {"s|p:txt2obj", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "txt2obj", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; const char *txt; int name = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &txt, &name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("txt2obj", 1, "str", args[0]); + goto exit; + } + Py_ssize_t txt_length; + txt = PyUnicode_AsUTF8AndSize(args[0], &txt_length); + if (txt == NULL) { + goto exit; + } + if (strlen(txt) != (size_t)txt_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + name = PyObject_IsTrue(args[1]); + if (name < 0) { + goto exit; + } +skip_optional_pos: return_value = _ssl_txt2obj_impl(module, txt, name); exit: @@ -1203,11 +1367,25 @@ _ssl_enum_certificates(PyObject *module, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"store_name", NULL}; - static _PyArg_Parser _parser = {"s:enum_certificates", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "enum_certificates", 0}; + PyObject *argsbuf[1]; const char *store_name; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &store_name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("enum_certificates", 1, "str", args[0]); + goto exit; + } + Py_ssize_t store_name_length; + store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); + if (store_name == NULL) { + goto exit; + } + if (strlen(store_name) != (size_t)store_name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } return_value = _ssl_enum_certificates_impl(module, store_name); @@ -1242,11 +1420,25 @@ _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"store_name", NULL}; - static _PyArg_Parser _parser = {"s:enum_crls", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "enum_crls", 0}; + PyObject *argsbuf[1]; const char *store_name; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &store_name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("enum_crls", 1, "str", args[0]); + goto exit; + } + Py_ssize_t store_name_length; + store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length); + if (store_name == NULL) { + goto exit; + } + if (strlen(store_name) != (size_t)store_name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } return_value = _ssl_enum_crls_impl(module, store_name); @@ -1284,4 +1476,4 @@ exit: #ifndef _SSL_ENUM_CRLS_METHODDEF #define _SSL_ENUM_CRLS_METHODDEF #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */ -/*[clinic end generated code: output=ac3fb15ca27500f2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a399d0eb393b6fab input=a9049054013a1b77]*/ diff --git a/Modules/clinic/_struct.c.h b/Modules/clinic/_struct.c.h index 2cc2d21..908c442 100644 --- a/Modules/clinic/_struct.c.h +++ b/Modules/clinic/_struct.c.h @@ -21,13 +21,17 @@ Struct___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"format", NULL}; - static _PyArg_Parser _parser = {"O:Struct", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Struct", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *format; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &format)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + format = fastargs[0]; return_value = Struct___init___impl((PyStructObject *)self, format); exit: @@ -100,14 +104,44 @@ Struct_unpack_from(PyStructObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"buffer", "offset", NULL}; - static _PyArg_Parser _parser = {"y*|n:unpack_from", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "unpack_from", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer buffer = {NULL, NULL}; Py_ssize_t offset = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &buffer, &offset)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + if (PyObject_GetBuffer(args[0], &buffer, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack_from", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + offset = ival; + } +skip_optional_pos: return_value = Struct_unpack_from_impl(self, &buffer, offset); exit: @@ -257,15 +291,48 @@ unpack_from(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "buffer", "offset", NULL}; - static _PyArg_Parser _parser = {"O&y*|n:unpack_from", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "unpack_from", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyStructObject *s_object = NULL; Py_buffer buffer = {NULL, NULL}; Py_ssize_t offset = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - cache_struct_converter, &s_object, &buffer, &offset)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!cache_struct_converter(args[0], &s_object)) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { goto exit; } + if (!PyBuffer_IsContiguous(&buffer, 'C')) { + _PyArg_BadArgument("unpack_from", 2, "contiguous buffer", args[1]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + offset = ival; + } +skip_optional_pos: return_value = unpack_from_impl(module, s_object, &buffer, offset); exit: @@ -319,4 +386,4 @@ exit: return return_value; } -/*[clinic end generated code: output=ac595db9d2b271aa input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b642e1002d25ebdd input=a9049054013a1b77]*/ diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h index 3295833..4043d89 100644 --- a/Modules/clinic/binascii.c.h +++ b/Modules/clinic/binascii.c.h @@ -50,14 +50,36 @@ binascii_b2a_uu(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "backtick", NULL}; - static _PyArg_Parser _parser = {"y*|$i:b2a_uu", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_uu", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int backtick = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &backtick)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_uu", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + backtick = _PyLong_AsInt(args[1]); + if (backtick == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = binascii_b2a_uu_impl(module, &data, backtick); exit: @@ -117,14 +139,36 @@ binascii_b2a_base64(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "newline", NULL}; - static _PyArg_Parser _parser = {"y*|$i:b2a_base64", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_base64", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int newline = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &newline)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_base64", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + newline = _PyLong_AsInt(args[1]); + if (newline == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_kwonly: return_value = binascii_b2a_base64_impl(module, &data, newline); exit: @@ -548,14 +592,32 @@ binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "header", NULL}; - static _PyArg_Parser _parser = {"O&|i:a2b_qp", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "a2b_qp", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int header = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - ascii_buffer_converter, &data, &header)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!ascii_buffer_converter(args[0], &data)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + header = _PyLong_AsInt(args[1]); + if (header == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = binascii_a2b_qp_impl(module, &data, header); exit: @@ -588,16 +650,66 @@ binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "quotetabs", "istext", "header", NULL}; - static _PyArg_Parser _parser = {"y*|iii:b2a_qp", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "b2a_qp", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int quotetabs = 0; int istext = 1; int header = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, "etabs, &istext, &header)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("b2a_qp", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + quotetabs = _PyLong_AsInt(args[1]); + if (quotetabs == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + istext = _PyLong_AsInt(args[2]); + if (istext == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + header = _PyLong_AsInt(args[3]); + if (header == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header); exit: @@ -608,4 +720,4 @@ exit: return return_value; } -/*[clinic end generated code: output=7210a01a718da4a0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a4a38e162605aca2 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h index cc1b8f2..83c498c 100644 --- a/Modules/clinic/cmathmodule.c.h +++ b/Modules/clinic/cmathmodule.c.h @@ -897,17 +897,44 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL}; - static _PyArg_Parser _parser = {"DD|$dd:isclose", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; Py_complex a; Py_complex b; double rel_tol = 1e-09; double abs_tol = 0.0; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &a, &b, &rel_tol, &abs_tol)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + a = PyComplex_AsCComplex(args[0]); + if (PyErr_Occurred()) { + goto exit; + } + b = PyComplex_AsCComplex(args[1]); + if (PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + rel_tol = PyFloat_AsDouble(args[2]); + if (PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + abs_tol = PyFloat_AsDouble(args[3]); + if (PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: _return_value = cmath_isclose_impl(module, a, b, rel_tol, abs_tol); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -917,4 +944,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=86a365d23f34aaff input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c7afb866e593fa45 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/gcmodule.c.h b/Modules/clinic/gcmodule.c.h index eece045..22d2aa4 100644 --- a/Modules/clinic/gcmodule.c.h +++ b/Modules/clinic/gcmodule.c.h @@ -89,14 +89,29 @@ gc_collect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"generation", NULL}; - static _PyArg_Parser _parser = {"|i:collect", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "collect", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int generation = NUM_GENERATIONS - 1; Py_ssize_t _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &generation)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + generation = _PyLong_AsInt(args[0]); + if (generation == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: _return_value = gc_collect_impl(module, generation); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -238,13 +253,22 @@ gc_get_objects(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"generation", NULL}; - static _PyArg_Parser _parser = {"|O&:get_objects", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "get_objects", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; Py_ssize_t generation = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - _Py_convert_optional_to_ssize_t, &generation)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (!_Py_convert_optional_to_ssize_t(args[0], &generation)) { goto exit; } +skip_optional_pos: return_value = gc_get_objects_impl(module, generation); exit: @@ -349,4 +373,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored)) exit: return return_value; } -/*[clinic end generated code: output=d692bf475f0bb096 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e40d384b1f0d513c input=a9049054013a1b77]*/ diff --git a/Modules/clinic/grpmodule.c.h b/Modules/clinic/grpmodule.c.h index c2e54c9..ae99c50 100644 --- a/Modules/clinic/grpmodule.c.h +++ b/Modules/clinic/grpmodule.c.h @@ -21,13 +21,15 @@ grp_getgrgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"id", NULL}; - static _PyArg_Parser _parser = {"O:getgrgid", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "getgrgid", 0}; + PyObject *argsbuf[1]; PyObject *id; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &id)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + id = args[0]; return_value = grp_getgrgid_impl(module, id); exit: @@ -53,13 +55,22 @@ grp_getgrnam(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"name", NULL}; - static _PyArg_Parser _parser = {"U:getgrnam", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "getgrnam", 0}; + PyObject *argsbuf[1]; PyObject *name; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("getgrnam", 1, "str", args[0]); + goto exit; + } + if (PyUnicode_READY(args[0]) == -1) { + goto exit; + } + name = args[0]; return_value = grp_getgrnam_impl(module, name); exit: @@ -86,4 +97,4 @@ grp_getgrall(PyObject *module, PyObject *Py_UNUSED(ignored)) { return grp_getgrall_impl(module); } -/*[clinic end generated code: output=ab10233f6015bc0a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2aa6c60873d41ee8 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/itertoolsmodule.c.h b/Modules/clinic/itertoolsmodule.c.h index bcf4c5f..b43ce64 100644 --- a/Modules/clinic/itertoolsmodule.c.h +++ b/Modules/clinic/itertoolsmodule.c.h @@ -23,14 +23,24 @@ itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "key", NULL}; - static _PyArg_Parser _parser = {"O|O:groupby", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "groupby", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *it; PyObject *keyfunc = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &it, &keyfunc)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + it = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + keyfunc = fastargs[1]; +skip_optional_pos: return_value = itertools_groupby_impl(type, it, keyfunc); exit: @@ -334,14 +344,35 @@ itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "r", NULL}; - static _PyArg_Parser _parser = {"On:combinations", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "combinations", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *iterable; Py_ssize_t r; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &iterable, &r)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + iterable = fastargs[0]; + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + r = ival; + } return_value = itertools_combinations_impl(type, iterable, r); exit: @@ -366,14 +397,35 @@ itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "r", NULL}; - static _PyArg_Parser _parser = {"On:combinations_with_replacement", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "combinations_with_replacement", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *iterable; Py_ssize_t r; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &iterable, &r)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + iterable = fastargs[0]; + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(fastargs[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + r = ival; + } return_value = itertools_combinations_with_replacement_impl(type, iterable, r); exit: @@ -397,14 +449,24 @@ itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "r", NULL}; - static _PyArg_Parser _parser = {"O|O:permutations", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "permutations", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *iterable; PyObject *robj = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &iterable, &robj)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + iterable = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + robj = fastargs[1]; +skip_optional_pos: return_value = itertools_permutations_impl(type, iterable, robj); exit: @@ -426,15 +488,35 @@ itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "func", "initial", NULL}; - static _PyArg_Parser _parser = {"O|O$O:accumulate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "accumulate", 0}; + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *iterable; PyObject *binop = Py_None; PyObject *initial = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &iterable, &binop, &initial)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + iterable = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[1]) { + binop = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + initial = fastargs[2]; +skip_optional_kwonly: return_value = itertools_accumulate_impl(type, iterable, binop, initial); exit: @@ -458,14 +540,19 @@ itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"data", "selectors", NULL}; - static _PyArg_Parser _parser = {"OO:compress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *seq1; PyObject *seq2; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &seq1, &seq2)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + seq1 = fastargs[0]; + seq2 = fastargs[1]; return_value = itertools_compress_impl(type, seq1, seq2); exit: @@ -527,17 +614,32 @@ itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"start", "step", NULL}; - static _PyArg_Parser _parser = {"|OO:count", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "count", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *long_cnt = NULL; PyObject *long_step = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &long_cnt, &long_step)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + long_cnt = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + long_step = fastargs[1]; +skip_optional_pos: return_value = itertools_count_impl(type, long_cnt, long_step); exit: return return_value; } -/*[clinic end generated code: output=3d0ca69707b60715 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=04c49debcae96003 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index b99a8de..1806a01 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -536,17 +536,44 @@ math_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL}; - static _PyArg_Parser _parser = {"dd|$dd:isclose", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; double a; double b; double rel_tol = 1e-09; double abs_tol = 0.0; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &a, &b, &rel_tol, &abs_tol)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + a = PyFloat_AsDouble(args[0]); + if (PyErr_Occurred()) { + goto exit; + } + b = PyFloat_AsDouble(args[1]); + if (PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + rel_tol = PyFloat_AsDouble(args[2]); + if (PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + abs_tol = PyFloat_AsDouble(args[3]); + if (PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: _return_value = math_isclose_impl(module, a, b, rel_tol, abs_tol); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -580,17 +607,25 @@ math_prod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "start", NULL}; - static _PyArg_Parser _parser = {"O|$O:prod", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "prod", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *iterable; PyObject *start = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &iterable, &start)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + iterable = args[0]; + if (!noptargs) { + goto skip_optional_kwonly; + } + start = args[1]; +skip_optional_kwonly: return_value = math_prod_impl(module, iterable, start); exit: return return_value; } -/*[clinic end generated code: output=20505690ca6fe402 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=96e71135dce41c48 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/md5module.c.h b/Modules/clinic/md5module.c.h index 67cb48c..12484cc 100644 --- a/Modules/clinic/md5module.c.h +++ b/Modules/clinic/md5module.c.h @@ -82,16 +82,23 @@ _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", NULL}; - static _PyArg_Parser _parser = {"|O:md5", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "md5", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + string = args[0]; +skip_optional_pos: return_value = _md5_md5_impl(module, string); exit: return return_value; } -/*[clinic end generated code: output=83cb1aef575f13bc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=53133f08cf9095fc input=a9049054013a1b77]*/ diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index dc5f3b1..55f2cbb 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -38,15 +38,36 @@ os_stat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&|$O&p:stat", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("stat", "path", 0, 1); int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[1]) { + if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); exit: @@ -76,14 +97,26 @@ os_lstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|$O&:lstat", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "lstat", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_lstat_impl(module, &path, dir_fd); exit: @@ -137,7 +170,9 @@ os_access(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&i|$O&pp:access", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "access", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("access", "path", 0, 0); int mode; int dir_fd = DEFAULT_DIR_FD; @@ -145,10 +180,47 @@ os_access(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!FACCESSAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + effective_ids = PyObject_IsTrue(args[3]); + if (effective_ids < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -245,11 +317,15 @@ os_chdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"O&:chdir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "chdir", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } return_value = os_chdir_impl(module, &path); @@ -283,11 +359,15 @@ os_fchdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"O&:fchdir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fchdir", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } return_value = os_fchdir_impl(module, fd); @@ -336,16 +416,46 @@ os_chmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&i|$O&p:chmod", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "chmod", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("chmod", "path", 0, PATH_HAVE_FCHMOD); int mode; int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!FCHMODAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[3]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); exit: @@ -376,12 +486,31 @@ os_fchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "mode", NULL}; - static _PyArg_Parser _parser = {"ii:fchmod", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fchmod", 0}; + PyObject *argsbuf[2]; int fd; int mode; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fd, &mode)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { goto exit; } return_value = os_fchmod_impl(module, fd, mode); @@ -414,12 +543,25 @@ os_lchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", NULL}; - static _PyArg_Parser _parser = {"O&i:lchmod", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "lchmod", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0); int mode; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &mode)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { goto exit; } return_value = os_lchmod_impl(module, &path, mode); @@ -459,15 +601,33 @@ os_chflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&k|p:chflags", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "chflags", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("chflags", "path", 0, 0); unsigned long flags; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &flags, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + if (!PyLong_Check(args[1])) { + _PyArg_BadArgument("chflags", 2, "int", args[1]); + goto exit; + } + flags = PyLong_AsUnsignedLongMask(args[1]); + if (!noptargs) { + goto skip_optional_pos; + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_pos: return_value = os_chflags_impl(module, &path, flags, follow_symlinks); exit: @@ -501,14 +661,23 @@ os_lchflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", NULL}; - static _PyArg_Parser _parser = {"O&k:lchflags", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "lchflags", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0); unsigned long flags; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &flags)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + if (!PyLong_Check(args[1])) { + _PyArg_BadArgument("lchflags", 2, "int", args[1]); + goto exit; + } + flags = PyLong_AsUnsignedLongMask(args[1]); return_value = os_lchflags_impl(module, &path, flags); exit: @@ -539,11 +708,15 @@ os_chroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"O&:chroot", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "chroot", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } return_value = os_chroot_impl(module, &path); @@ -576,11 +749,15 @@ os_fsync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"O&:fsync", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fsync", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } return_value = os_fsync_impl(module, fd); @@ -632,11 +809,15 @@ os_fdatasync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"O&:fdatasync", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fdatasync", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } return_value = os_fdatasync_impl(module, fd); @@ -691,17 +872,44 @@ os_chown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&O&O&|$O&p:chown", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "chown", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; path_t path = PATH_T_INITIALIZE("chown", "path", 0, PATH_HAVE_FCHOWN); uid_t uid; gid_t gid; int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &uid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &gid)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + if (!FCHOWNAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); exit: @@ -734,13 +942,29 @@ os_fchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "uid", "gid", NULL}; - static _PyArg_Parser _parser = {"iO&O&:fchown", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fchown", 0}; + PyObject *argsbuf[3]; int fd; uid_t uid; gid_t gid; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &uid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &gid)) { goto exit; } return_value = os_fchown_impl(module, fd, uid, gid); @@ -773,13 +997,23 @@ os_lchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "uid", "gid", NULL}; - static _PyArg_Parser _parser = {"O&O&O&:lchown", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "lchown", 0}; + PyObject *argsbuf[3]; path_t path = PATH_T_INITIALIZE("lchown", "path", 0, 0); uid_t uid; gid_t gid; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!_Py_Uid_Converter(args[1], &uid)) { + goto exit; + } + if (!_Py_Gid_Converter(args[2], &gid)) { goto exit; } return_value = os_lchown_impl(module, &path, uid, gid); @@ -860,17 +1094,49 @@ os_link(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&O&|$O&O&p:link", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "link", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("link", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("link", "dst", 0, 0); int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { goto exit; } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!dir_fd_converter(args[2], &src_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!dir_fd_converter(args[3], &dst_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); exit: @@ -912,13 +1178,22 @@ os_listdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"|O&:listdir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "listdir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (!path_converter(args[0], &path)) { + goto exit; + } +skip_optional_pos: return_value = os_listdir_impl(module, &path); exit: @@ -1027,11 +1302,15 @@ os__getvolumepathname(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"O&:_getvolumepathname", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_getvolumepathname", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("_getvolumepathname", "path", 0, 0); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } return_value = os__getvolumepathname_impl(module, &path); @@ -1069,15 +1348,45 @@ os_mkdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|i$O&:mkdir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "mkdir", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("mkdir", "path", 0, 0); int mode = 511; int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!MKDIRAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_mkdir_impl(module, &path, mode, dir_fd); exit: @@ -1143,12 +1452,31 @@ os_getpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"which", "who", NULL}; - static _PyArg_Parser _parser = {"ii:getpriority", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "getpriority", 0}; + PyObject *argsbuf[2]; int which; int who; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &which, &who)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + which = _PyLong_AsInt(args[0]); + if (which == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + who = _PyLong_AsInt(args[1]); + if (who == -1 && PyErr_Occurred()) { goto exit; } return_value = os_getpriority_impl(module, which, who); @@ -1178,13 +1506,41 @@ os_setpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"which", "who", "priority", NULL}; - static _PyArg_Parser _parser = {"iii:setpriority", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "setpriority", 0}; + PyObject *argsbuf[3]; int which; int who; int priority; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &which, &who, &priority)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + which = _PyLong_AsInt(args[0]); + if (which == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + who = _PyLong_AsInt(args[1]); + if (who == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + priority = _PyLong_AsInt(args[2]); + if (priority == -1 && PyErr_Occurred()) { goto exit; } return_value = os_setpriority_impl(module, which, who, priority); @@ -1219,16 +1575,39 @@ os_rename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&O&|$O&O&:rename", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "rename", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("rename", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("rename", "dst", 0, 0); int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!dir_fd_converter(args[2], &src_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!dir_fd_converter(args[3], &dst_dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); exit: @@ -1264,16 +1643,39 @@ os_replace(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&O&|$O&O&:replace", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("replace", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("replace", "dst", 0, 0); int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + if (!dir_fd_converter(args[2], &src_dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (!dir_fd_converter(args[3], &dst_dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); exit: @@ -1307,14 +1709,26 @@ os_rmdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|$O&:rmdir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "rmdir", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_rmdir_impl(module, &path, dir_fd); exit: @@ -1382,12 +1796,16 @@ os_system(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"command", NULL}; - static _PyArg_Parser _parser = {"O&:system", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "system", 0}; + PyObject *argsbuf[1]; PyObject *command = NULL; long _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - PyUnicode_FSConverter, &command)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!PyUnicode_FSConverter(args[0], &command)) { goto exit; } _return_value = os_system_impl(module, command); @@ -1460,14 +1878,26 @@ os_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|$O&:unlink", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "unlink", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_unlink_impl(module, &path, dir_fd); exit: @@ -1499,14 +1929,26 @@ os_remove(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|$O&:remove", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "remove", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_remove_impl(module, &path, dir_fd); exit: @@ -1582,17 +2024,54 @@ os_utime(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&|O$OO&p:utime", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "utime", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("utime", "path", 0, PATH_UTIME_HAVE_FD); PyObject *times = NULL; PyObject *ns = NULL; int dir_fd = DEFAULT_DIR_FD; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, ×, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + times = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[2]) { + ns = args[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[3]) { + if (!FUTIMENSAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); exit: @@ -1619,11 +2098,21 @@ os__exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:_exit", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_exit", 0}; + PyObject *argsbuf[1]; int status; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } return_value = os__exit_impl(module, status); @@ -1702,15 +2191,21 @@ os_execve(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "argv", "env", NULL}; - static _PyArg_Parser _parser = {"O&OO:execve", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "execve", 0}; + PyObject *argsbuf[3]; path_t path = PATH_T_INITIALIZE("execve", "path", 0, PATH_HAVE_FEXECVE); PyObject *argv; PyObject *env; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &argv, &env)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + argv = args[1]; + env = args[2]; return_value = os_execve_impl(module, &path, argv, env); exit: @@ -1768,7 +2263,9 @@ os_posix_spawn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; - static _PyArg_Parser _parser = {"O&OO|$OOiiOOO:posix_spawn", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawn", 0}; + PyObject *argsbuf[10]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; path_t path = PATH_T_INITIALIZE("posix_spawn", "path", 0, 0); PyObject *argv; PyObject *env; @@ -1780,10 +2277,72 @@ os_posix_spawn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje PyObject *setsigdef = NULL; PyObject *scheduler = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &argv, &env, &file_actions, &setpgroup, &resetids, &setsid, &setsigmask, &setsigdef, &scheduler)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { goto exit; } + if (!path_converter(args[0], &path)) { + goto exit; + } + argv = args[1]; + env = args[2]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + file_actions = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + setpgroup = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + resetids = _PyLong_AsInt(args[5]); + if (resetids == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[6]) { + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + setsid = _PyLong_AsInt(args[6]); + if (setsid == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[7]) { + setsigmask = args[7]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[8]) { + setsigdef = args[8]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + scheduler = args[9]; +skip_optional_kwonly: return_value = os_posix_spawn_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); exit: @@ -1841,7 +2400,9 @@ os_posix_spawnp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; - static _PyArg_Parser _parser = {"O&OO|$OOiiOOO:posix_spawnp", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawnp", 0}; + PyObject *argsbuf[10]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; path_t path = PATH_T_INITIALIZE("posix_spawnp", "path", 0, 0); PyObject *argv; PyObject *env; @@ -1853,10 +2414,72 @@ os_posix_spawnp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj PyObject *setsigdef = NULL; PyObject *scheduler = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &argv, &env, &file_actions, &setpgroup, &resetids, &setsid, &setsigmask, &setsigdef, &scheduler)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + argv = args[1]; + env = args[2]; + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[3]) { + file_actions = args[3]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[4]) { + setpgroup = args[4]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + resetids = _PyLong_AsInt(args[5]); + if (resetids == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[6]) { + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + setsid = _PyLong_AsInt(args[6]); + if (setsid == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[7]) { + setsigmask = args[7]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[8]) { + setsigdef = args[8]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + scheduler = args[9]; +skip_optional_kwonly: return_value = os_posix_spawnp_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); exit: @@ -2016,15 +2639,34 @@ os_register_at_fork(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P { PyObject *return_value = NULL; static const char * const _keywords[] = {"before", "after_in_child", "after_in_parent", NULL}; - static _PyArg_Parser _parser = {"|$OOO:register_at_fork", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "register_at_fork", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *before = NULL; PyObject *after_in_child = NULL; PyObject *after_in_parent = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &before, &after_in_child, &after_in_parent)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + before = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (args[1]) { + after_in_child = args[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + after_in_parent = args[2]; +skip_optional_kwonly: return_value = os_register_at_fork_impl(module, before, after_in_child, after_in_parent); exit: @@ -2100,11 +2742,21 @@ os_sched_get_priority_max(PyObject *module, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"policy", NULL}; - static _PyArg_Parser _parser = {"i:sched_get_priority_max", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_max", 0}; + PyObject *argsbuf[1]; int policy; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &policy)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + policy = _PyLong_AsInt(args[0]); + if (policy == -1 && PyErr_Occurred()) { goto exit; } return_value = os_sched_get_priority_max_impl(module, policy); @@ -2134,11 +2786,21 @@ os_sched_get_priority_min(PyObject *module, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"policy", NULL}; - static _PyArg_Parser _parser = {"i:sched_get_priority_min", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_min", 0}; + PyObject *argsbuf[1]; int policy; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &policy)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + policy = _PyLong_AsInt(args[0]); + if (policy == -1 && PyErr_Occurred()) { goto exit; } return_value = os_sched_get_priority_min_impl(module, policy); @@ -2201,13 +2863,17 @@ os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sched_priority", NULL}; - static _PyArg_Parser _parser = {"O:sched_param", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sched_param", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *sched_priority; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &sched_priority)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + sched_priority = fastargs[0]; return_value = os_sched_param_impl(type, sched_priority); exit: @@ -3100,11 +3766,21 @@ os_wait3(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"options", NULL}; - static _PyArg_Parser _parser = {"i:wait3", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "wait3", 0}; + PyObject *argsbuf[1]; int options; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &options)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + options = _PyLong_AsInt(args[0]); + if (options == -1 && PyErr_Occurred()) { goto exit; } return_value = os_wait3_impl(module, options); @@ -3324,14 +4000,26 @@ os_readlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|$O&:readlink", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "readlink", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("readlink", "path", 0, 0); int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, READLINKAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!READLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: return_value = os_readlink_impl(module, &path, dir_fd); exit: @@ -3373,16 +4061,44 @@ os_symlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&O&|p$O&:symlink", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "symlink", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t src = PATH_T_INITIALIZE("symlink", "src", 0, 0); path_t dst = PATH_T_INITIALIZE("symlink", "dst", 0, 0); int target_is_directory = 0; int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &src)) { + goto exit; + } + if (!path_converter(args[1], &dst)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + target_is_directory = PyObject_IsTrue(args[2]); + if (target_is_directory < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!SYMLINKAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); exit: @@ -3600,17 +4316,56 @@ os_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&i|i$O&:open", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("open", "path", 0, 0); int flags; int mode = 511; int dir_fd = DEFAULT_DIR_FD; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[2]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!OPENAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { + goto exit; + } +skip_optional_kwonly: _return_value = os_open_impl(module, &path, flags, mode, dir_fd); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -3641,11 +4396,21 @@ os_close(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"i:close", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "close", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { goto exit; } return_value = os_close_impl(module, fd); @@ -3755,16 +4520,44 @@ os_dup2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "fd2", "inheritable", NULL}; - static _PyArg_Parser _parser = {"ii|p:dup2", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "dup2", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; int fd; int fd2; int inheritable = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fd, &fd2, &inheritable)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd2 = _PyLong_AsInt(args[1]); + if (fd2 == -1 && PyErr_Occurred()) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + inheritable = PyObject_IsTrue(args[2]); + if (inheritable < 0) { goto exit; } +skip_optional_pos: _return_value = os_dup2_impl(module, fd, fd2, inheritable); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -4274,11 +5067,21 @@ os_fstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"i:fstat", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fstat", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { goto exit; } return_value = os_fstat_impl(module, fd); @@ -4616,15 +5419,45 @@ os_mkfifo(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|i$O&:mkfifo", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "mkfifo", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("mkfifo", "path", 0, 0); int mode = 438; int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!MKFIFOAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_mkfifo_impl(module, &path, mode, dir_fd); exit: @@ -4668,16 +5501,54 @@ os_mknod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kw { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "mode", "device", "dir_fd", NULL}; - static _PyArg_Parser _parser = {"O&|iO&$O&:mknod", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "mknod", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; path_t path = PATH_T_INITIALIZE("mknod", "path", 0, 0); int mode = 384; dev_t device = 0; int dir_fd = DEFAULT_DIR_FD; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + mode = _PyLong_AsInt(args[1]); + if (mode == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (!_Py_Dev_Converter(args[2], &device)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + if (!MKNODAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { goto exit; } +skip_optional_kwonly: return_value = os_mknod_impl(module, &path, mode, device, dir_fd); exit: @@ -4882,12 +5753,19 @@ os_truncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "length", NULL}; - static _PyArg_Parser _parser = {"O&O&:truncate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "truncate", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE); Py_off_t length; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, Py_off_t_converter, &length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!Py_off_t_converter(args[1], &length)) { goto exit; } return_value = os_truncate_impl(module, &path, length); @@ -5242,12 +6120,22 @@ os_WIFCONTINUED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WIFCONTINUED", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFCONTINUED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WIFCONTINUED_impl(module, status); @@ -5281,12 +6169,22 @@ os_WIFSTOPPED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WIFSTOPPED", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFSTOPPED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WIFSTOPPED_impl(module, status); @@ -5320,12 +6218,22 @@ os_WIFSIGNALED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WIFSIGNALED", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFSIGNALED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WIFSIGNALED_impl(module, status); @@ -5359,12 +6267,22 @@ os_WIFEXITED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WIFEXITED", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WIFEXITED", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WIFEXITED_impl(module, status); @@ -5398,12 +6316,22 @@ os_WEXITSTATUS(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WEXITSTATUS", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WEXITSTATUS", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WEXITSTATUS_impl(module, status); @@ -5437,12 +6365,22 @@ os_WTERMSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WTERMSIG", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WTERMSIG", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WTERMSIG_impl(module, status); @@ -5476,12 +6414,22 @@ os_WSTOPSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"status", NULL}; - static _PyArg_Parser _parser = {"i:WSTOPSIG", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "WSTOPSIG", 0}; + PyObject *argsbuf[1]; int status; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &status)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + status = _PyLong_AsInt(args[0]); + if (status == -1 && PyErr_Occurred()) { goto exit; } _return_value = os_WSTOPSIG_impl(module, status); @@ -5558,11 +6506,15 @@ os_statvfs(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"O&:statvfs", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "statvfs", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } return_value = os_statvfs_impl(module, &path); @@ -5595,11 +6547,15 @@ os__getdiskusage(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"O&:_getdiskusage", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "_getdiskusage", 0}; + PyObject *argsbuf[1]; path_t path = PATH_T_INITIALIZE("_getdiskusage", "path", 0, 0); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { goto exit; } return_value = os__getdiskusage_impl(module, &path); @@ -5687,13 +6643,20 @@ os_pathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "name", NULL}; - static _PyArg_Parser _parser = {"O&O&:pathconf", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "pathconf", 0}; + PyObject *argsbuf[2]; path_t path = PATH_T_INITIALIZE("pathconf", "path", 0, PATH_HAVE_FPATHCONF); int name; long _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, conv_path_confname, &name)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!conv_path_confname(args[1], &name)) { goto exit; } _return_value = os_pathconf_impl(module, &path, name); @@ -5901,11 +6864,21 @@ os_device_encoding(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"i:device_encoding", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "device_encoding", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + fd = _PyLong_AsInt(args[0]); + if (fd == -1 && PyErr_Occurred()) { goto exit; } return_value = os_device_encoding_impl(module, fd); @@ -6067,15 +7040,31 @@ os_getxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&O&|$p:getxattr", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "getxattr", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("getxattr", "path", 0, 1); path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0); int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, path_converter, &attribute, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!path_converter(args[1], &attribute)) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); exit: @@ -6115,17 +7104,58 @@ os_setxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&O&y*|i$p:setxattr", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "setxattr", 0}; + PyObject *argsbuf[5]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; path_t path = PATH_T_INITIALIZE("setxattr", "path", 0, 1); path_t attribute = PATH_T_INITIALIZE("setxattr", "attribute", 0, 0); Py_buffer value = {NULL, NULL}; int flags = 0; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!path_converter(args[1], &attribute)) { + goto exit; + } + if (PyObject_GetBuffer(args[2], &value, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&value, 'C')) { + _PyArg_BadArgument("setxattr", 3, "contiguous buffer", args[2]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[3]) { + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[3]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[4]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); exit: @@ -6168,15 +7198,31 @@ os_removexattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"O&O&|$p:removexattr", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "removexattr", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; path_t path = PATH_T_INITIALIZE("removexattr", "path", 0, 1); path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0); int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, path_converter, &attribute, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!path_converter(args[1], &attribute)) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[2]); + if (follow_symlinks < 0) { + goto exit; + } +skip_optional_kwonly: return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); exit: @@ -6215,14 +7261,36 @@ os_listxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", "follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|O&$p:listxattr", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "listxattr", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1); int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path, &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (!path_converter(args[0], &path)) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } +skip_optional_pos: + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[1]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_listxattr_impl(module, &path, follow_symlinks); exit: @@ -6593,13 +7661,23 @@ os_DirEntry_stat(DirEntry *self, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:stat", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: return_value = os_DirEntry_stat_impl(self, follow_symlinks); exit: @@ -6623,14 +7701,24 @@ os_DirEntry_is_dir(DirEntry *self, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_dir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "is_dir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: _return_value = os_DirEntry_is_dir_impl(self, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -6658,14 +7746,24 @@ os_DirEntry_is_file(DirEntry *self, PyObject *const *args, Py_ssize_t nargs, PyO { PyObject *return_value = NULL; static const char * const _keywords[] = {"follow_symlinks", NULL}; - static _PyArg_Parser _parser = {"|$p:is_file", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "is_file", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int follow_symlinks = 1; int _return_value; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &follow_symlinks)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + follow_symlinks = PyObject_IsTrue(args[0]); + if (follow_symlinks < 0) { goto exit; } +skip_optional_kwonly: _return_value = os_DirEntry_is_file_impl(self, follow_symlinks); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; @@ -6735,13 +7833,22 @@ os_scandir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"|O&:scandir", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "scandir", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; path_t path = PATH_T_INITIALIZE("scandir", "path", 1, PATH_HAVE_FDOPENDIR); - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - path_converter, &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (!path_converter(args[0], &path)) { goto exit; } +skip_optional_pos: return_value = os_scandir_impl(module, &path); exit: @@ -6772,13 +7879,15 @@ os_fspath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *k { PyObject *return_value = NULL; static const char * const _keywords[] = {"path", NULL}; - static _PyArg_Parser _parser = {"O:fspath", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fspath", 0}; + PyObject *argsbuf[1]; PyObject *path; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &path)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + path = args[0]; return_value = os_fspath_impl(module, path); exit: @@ -6804,14 +7913,46 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"size", "flags", NULL}; - static _PyArg_Parser _parser = {"n|i:getrandom", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "getrandom", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_ssize_t size; int flags = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &size, &flags)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + size = ival; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = os_getrandom_impl(module, size, flags); exit: @@ -7339,4 +8480,4 @@ exit: #ifndef OS_GETRANDOM_METHODDEF #define OS_GETRANDOM_METHODDEF #endif /* !defined(OS_GETRANDOM_METHODDEF) */ -/*[clinic end generated code: output=bb677205c036deca input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1a9c62f5841221ae input=a9049054013a1b77]*/ diff --git a/Modules/clinic/pyexpat.c.h b/Modules/clinic/pyexpat.c.h index 3fe7b64..dfb27d5 100644 --- a/Modules/clinic/pyexpat.c.h +++ b/Modules/clinic/pyexpat.c.h @@ -297,15 +297,68 @@ pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL}; - static _PyArg_Parser _parser = {"|zzO:ParserCreate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "ParserCreate", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *namespace_separator = NULL; PyObject *intern = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &encoding, &namespace_separator, &intern)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (args[0] == Py_None) { + encoding = NULL; + } + else if (PyUnicode_Check(args[0])) { + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ParserCreate", 1, "str or None", args[0]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[1]) { + if (args[1] == Py_None) { + namespace_separator = NULL; + } + else if (PyUnicode_Check(args[1])) { + Py_ssize_t namespace_separator_length; + namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length); + if (namespace_separator == NULL) { + goto exit; + } + if (strlen(namespace_separator) != (size_t)namespace_separator_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + } + else { + _PyArg_BadArgument("ParserCreate", 2, "str or None", args[1]); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + intern = args[2]; +skip_optional_pos: return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern); exit: @@ -348,4 +401,4 @@ exit: #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ -/*[clinic end generated code: output=0f18b756d82b78a5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e48f37d326956bdd input=a9049054013a1b77]*/ diff --git a/Modules/clinic/selectmodule.c.h b/Modules/clinic/selectmodule.c.h index c2ef26f..9015816 100644 --- a/Modules/clinic/selectmodule.c.h +++ b/Modules/clinic/selectmodule.c.h @@ -512,14 +512,45 @@ select_epoll(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sizehint", "flags", NULL}; - static _PyArg_Parser _parser = {"|ii:epoll", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "epoll", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; int sizehint = -1; int flags = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &sizehint, &flags)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + if (PyFloat_Check(fastargs[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + sizehint = _PyLong_AsInt(fastargs[0]); + if (sizehint == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(fastargs[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(fastargs[1]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = select_epoll_impl(type, sizehint, flags); exit: @@ -638,14 +669,32 @@ select_epoll_register(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "eventmask", NULL}; - static _PyArg_Parser _parser = {"O&|I:register", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "register", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; int fd; unsigned int eventmask = EPOLLIN | EPOLLPRI | EPOLLOUT; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd, &eventmask)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + eventmask = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (eventmask == (unsigned int)-1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = select_epoll_register_impl(self, fd, eventmask); exit: @@ -679,12 +728,25 @@ select_epoll_modify(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", "eventmask", NULL}; - static _PyArg_Parser _parser = {"O&I:modify", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "modify", 0}; + PyObject *argsbuf[2]; int fd; unsigned int eventmask; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd, &eventmask)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + eventmask = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); + if (eventmask == (unsigned int)-1 && PyErr_Occurred()) { goto exit; } return_value = select_epoll_modify_impl(self, fd, eventmask); @@ -717,11 +779,15 @@ select_epoll_unregister(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"fd", NULL}; - static _PyArg_Parser _parser = {"O&:unregister", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "unregister", 0}; + PyObject *argsbuf[1]; int fd; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - fildes_converter, &fd)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!fildes_converter(args[0], &fd)) { goto exit; } return_value = select_epoll_unregister_impl(self, fd); @@ -761,14 +827,35 @@ select_epoll_poll(pyEpoll_Object *self, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"timeout", "maxevents", NULL}; - static _PyArg_Parser _parser = {"|Oi:poll", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "poll", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *timeout_obj = Py_None; int maxevents = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &timeout_obj, &maxevents)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + timeout_obj = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + maxevents = _PyLong_AsInt(args[1]); + if (maxevents == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = select_epoll_poll_impl(self, timeout_obj, maxevents); exit: @@ -1128,4 +1215,4 @@ exit: #ifndef SELECT_KQUEUE_CONTROL_METHODDEF #define SELECT_KQUEUE_CONTROL_METHODDEF #endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */ -/*[clinic end generated code: output=3e40b33a3294d03d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=03041f3d09b04a3d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha1module.c.h b/Modules/clinic/sha1module.c.h index af29173..001c6af 100644 --- a/Modules/clinic/sha1module.c.h +++ b/Modules/clinic/sha1module.c.h @@ -82,16 +82,23 @@ _sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", NULL}; - static _PyArg_Parser _parser = {"|O:sha1", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha1", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + string = args[0]; +skip_optional_pos: return_value = _sha1_sha1_impl(module, string); exit: return return_value; } -/*[clinic end generated code: output=3bae85313ee5a3b5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1ae7e73ec84a27d5 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha256module.c.h b/Modules/clinic/sha256module.c.h index 14a88a2..658abb1 100644 --- a/Modules/clinic/sha256module.c.h +++ b/Modules/clinic/sha256module.c.h @@ -82,13 +82,20 @@ _sha256_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", NULL}; - static _PyArg_Parser _parser = {"|O:sha256", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha256", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + string = args[0]; +skip_optional_pos: return_value = _sha256_sha256_impl(module, string); exit: @@ -112,16 +119,23 @@ _sha256_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", NULL}; - static _PyArg_Parser _parser = {"|O:sha224", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha224", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + string = args[0]; +skip_optional_pos: return_value = _sha256_sha224_impl(module, string); exit: return return_value; } -/*[clinic end generated code: output=fb208641d4bc3b5f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c54d0956ec88409d input=a9049054013a1b77]*/ diff --git a/Modules/clinic/sha512module.c.h b/Modules/clinic/sha512module.c.h index 7e08701..459a934 100644 --- a/Modules/clinic/sha512module.c.h +++ b/Modules/clinic/sha512module.c.h @@ -82,13 +82,20 @@ _sha512_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", NULL}; - static _PyArg_Parser _parser = {"|O:sha512", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha512", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + string = args[0]; +skip_optional_pos: return_value = _sha512_sha512_impl(module, string); exit: @@ -112,16 +119,23 @@ _sha512_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"string", NULL}; - static _PyArg_Parser _parser = {"|O:sha384", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sha384", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *string = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &string)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + string = args[0]; +skip_optional_pos: return_value = _sha512_sha384_impl(module, string); exit: return return_value; } -/*[clinic end generated code: output=3706fa47bea06c0b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=580df4b667084a7e input=a9049054013a1b77]*/ diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h index 8e5f96a..aa57920 100644 --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -24,14 +24,36 @@ zlib_compress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "level", NULL}; - static _PyArg_Parser _parser = {"y*|i:compress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int level = Z_DEFAULT_COMPRESSION; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &level)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("compress", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + level = _PyLong_AsInt(args[1]); + if (level == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = zlib_compress_impl(module, &data, level); exit: @@ -68,15 +90,45 @@ zlib_decompress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "wbits", "bufsize", NULL}; - static _PyArg_Parser _parser = {"y*|iO&:decompress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; int wbits = MAX_WBITS; Py_ssize_t bufsize = DEF_BUF_SIZE; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, &wbits, ssize_t_converter, &bufsize)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); + if (!args) { goto exit; } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wbits = _PyLong_AsInt(args[1]); + if (wbits == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!ssize_t_converter(args[2], &bufsize)) { + goto exit; + } +skip_optional_pos: return_value = zlib_decompress_impl(module, &data, wbits, bufsize); exit: @@ -130,7 +182,9 @@ zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"level", "method", "wbits", "memLevel", "strategy", "zdict", NULL}; - static _PyArg_Parser _parser = {"|iiiiiy*:compressobj", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "compressobj", 0}; + PyObject *argsbuf[6]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int level = Z_DEFAULT_COMPRESSION; int method = DEFLATED; int wbits = MAX_WBITS; @@ -138,10 +192,91 @@ zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb int strategy = Z_DEFAULT_STRATEGY; Py_buffer zdict = {NULL, NULL}; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &level, &method, &wbits, &memLevel, &strategy, &zdict)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 6, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + level = _PyLong_AsInt(args[0]); + if (level == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[1]) { + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + method = _PyLong_AsInt(args[1]); + if (method == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wbits = _PyLong_AsInt(args[2]); + if (wbits == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[3]) { + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + memLevel = _PyLong_AsInt(args[3]); + if (memLevel == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + strategy = _PyLong_AsInt(args[4]); + if (strategy == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyObject_GetBuffer(args[5], &zdict, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&zdict, 'C')) { + _PyArg_BadArgument("compressobj", 6, "contiguous buffer", args[5]); + goto exit; + } +skip_optional_pos: return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict); exit: @@ -176,14 +311,35 @@ zlib_decompressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"wbits", "zdict", NULL}; - static _PyArg_Parser _parser = {"|iO:decompressobj", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decompressobj", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int wbits = MAX_WBITS; PyObject *zdict = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &wbits, &zdict)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + wbits = _PyLong_AsInt(args[0]); + if (wbits == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + zdict = args[1]; +skip_optional_pos: return_value = zlib_decompressobj_impl(module, wbits, zdict); exit: @@ -262,14 +418,30 @@ zlib_Decompress_decompress(compobject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "max_length", NULL}; - static _PyArg_Parser _parser = {"y*|O&:decompress", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; Py_buffer data = {NULL, NULL}; Py_ssize_t max_length = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &data, ssize_t_converter, &max_length)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&data, 'C')) { + _PyArg_BadArgument("decompress", 1, "contiguous buffer", args[0]); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (!ssize_t_converter(args[1], &max_length)) { goto exit; } +skip_optional_pos: return_value = zlib_Decompress_decompress_impl(self, &data, max_length); exit: @@ -613,4 +785,4 @@ exit: #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ -/*[clinic end generated code: output=b3acec2384f18782 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=feb079cebbbaacd6 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index a4669f5..da1dc6a 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -62,14 +62,22 @@ bytearray_translate(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "delete", NULL}; - static _PyArg_Parser _parser = {"O|O:translate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *table; PyObject *deletechars = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &table, &deletechars)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + table = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + deletechars = args[1]; +skip_optional_pos: return_value = bytearray_translate_impl(self, table, deletechars); exit: @@ -239,14 +247,43 @@ bytearray_split(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"|On:split", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sep, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = bytearray_split_impl(self, sep, maxsplit); exit: @@ -314,14 +351,43 @@ bytearray_rsplit(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"|On:rsplit", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sep, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = bytearray_rsplit_impl(self, sep, maxsplit); exit: @@ -654,14 +720,51 @@ bytearray_decode(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"|ss:decode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("decode", 1, "str", args[0]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("decode", 2, "str", args[1]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = bytearray_decode_impl(self, encoding, errors); exit: @@ -701,13 +804,28 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t { PyObject *return_value = NULL; static const char * const _keywords[] = {"keepends", NULL}; - static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int keepends = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &keepends)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + keepends = _PyLong_AsInt(args[0]); + if (keepends == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = bytearray_splitlines_impl(self, keepends); exit: @@ -824,4 +942,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=f4353c27dcb4a13d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=272fcb836b92da32 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index d75bbf1..b030783 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -27,14 +27,43 @@ bytes_split(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObje { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"|On:split", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sep, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = bytes_split_impl(self, sep, maxsplit); exit: @@ -154,14 +183,43 @@ bytes_rsplit(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"|On:rsplit", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sep, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = bytes_rsplit_impl(self, sep, maxsplit); exit: @@ -309,14 +367,22 @@ bytes_translate(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "delete", NULL}; - static _PyArg_Parser _parser = {"O|O:translate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *table; PyObject *deletechars = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &table, &deletechars)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + table = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + deletechars = args[1]; +skip_optional_pos: return_value = bytes_translate_impl(self, table, deletechars); exit: @@ -487,14 +553,51 @@ bytes_decode(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"|ss:decode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("decode", 1, "str", args[0]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("decode", 2, "str", args[1]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } +skip_optional_pos: return_value = bytes_decode_impl(self, encoding, errors); exit: @@ -521,13 +624,28 @@ bytes_splitlines(PyBytesObject *self, PyObject *const *args, Py_ssize_t nargs, P { PyObject *return_value = NULL; static const char * const _keywords[] = {"keepends", NULL}; - static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int keepends = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &keepends)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + keepends = _PyLong_AsInt(args[0]); + if (keepends == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = bytes_splitlines_impl(self, keepends); exit: @@ -568,4 +686,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=c6621bda84e63e51 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=af9f51b9b185567d input=a9049054013a1b77]*/ diff --git a/Objects/clinic/complexobject.c.h b/Objects/clinic/complexobject.c.h index 0cbfb79..8caa910 100644 --- a/Objects/clinic/complexobject.c.h +++ b/Objects/clinic/complexobject.c.h @@ -18,17 +18,32 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"real", "imag", NULL}; - static _PyArg_Parser _parser = {"|OO:complex", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "complex", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *r = _PyLong_Zero; PyObject *i = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &r, &i)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + r = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + i = fastargs[1]; +skip_optional_pos: return_value = complex_new_impl(type, r, i); exit: return return_value; } -/*[clinic end generated code: output=5017b2458bdc4ecd input=a9049054013a1b77]*/ +/*[clinic end generated code: output=a0fe23fdbdc9b06b input=a9049054013a1b77]*/ diff --git a/Objects/clinic/descrobject.c.h b/Objects/clinic/descrobject.c.h index 71b1966..d248b91 100644 --- a/Objects/clinic/descrobject.c.h +++ b/Objects/clinic/descrobject.c.h @@ -10,13 +10,17 @@ mappingproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"mapping", NULL}; - static _PyArg_Parser _parser = {"O:mappingproxy", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "mappingproxy", 0}; + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *mapping; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &mapping)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { goto exit; } + mapping = fastargs[0]; return_value = mappingproxy_new_impl(type, mapping); exit: @@ -69,19 +73,46 @@ property_init(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"fget", "fset", "fdel", "doc", NULL}; - static _PyArg_Parser _parser = {"|OOOO:property", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "property", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *fget = NULL; PyObject *fset = NULL; PyObject *fdel = NULL; PyObject *doc = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &fget, &fset, &fdel, &doc)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 4, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[0]) { + fget = fastargs[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[1]) { + fset = fastargs[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[2]) { + fdel = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + doc = fastargs[3]; +skip_optional_pos: return_value = property_init_impl((propertyobject *)self, fget, fset, fdel, doc); exit: return return_value; } -/*[clinic end generated code: output=729021fa9cdc46be input=a9049054013a1b77]*/ +/*[clinic end generated code: output=916624e717862abc input=a9049054013a1b77]*/ diff --git a/Objects/clinic/enumobject.c.h b/Objects/clinic/enumobject.c.h index 27da294..09d4c87 100644 --- a/Objects/clinic/enumobject.c.h +++ b/Objects/clinic/enumobject.c.h @@ -25,14 +25,24 @@ enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "start", NULL}; - static _PyArg_Parser _parser = {"O|O:enumerate", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "enumerate", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *iterable; PyObject *start = 0; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &iterable, &start)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + iterable = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + start = fastargs[1]; +skip_optional_pos: return_value = enum_new_impl(type, iterable, start); exit: @@ -67,4 +77,4 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=831cec3db0e987c9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e18c3fefcf914ec7 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/funcobject.c.h b/Objects/clinic/funcobject.c.h index 4c54483..929797b 100644 --- a/Objects/clinic/funcobject.c.h +++ b/Objects/clinic/funcobject.c.h @@ -28,20 +28,51 @@ func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"code", "globals", "name", "argdefs", "closure", NULL}; - static _PyArg_Parser _parser = {"O!O!|OOO:function", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "function", 0}; + PyObject *argsbuf[5]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; PyCodeObject *code; PyObject *globals; PyObject *name = Py_None; PyObject *defaults = Py_None; PyObject *closure = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &PyCode_Type, &code, &PyDict_Type, &globals, &name, &defaults, &closure)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 5, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!PyObject_TypeCheck(fastargs[0], &PyCode_Type)) { + _PyArg_BadArgument("function", 1, (&PyCode_Type)->tp_name, fastargs[0]); + goto exit; + } + code = (PyCodeObject *)fastargs[0]; + if (!PyDict_Check(fastargs[1])) { + _PyArg_BadArgument("function", 2, "dict", fastargs[1]); + goto exit; + } + globals = fastargs[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (fastargs[2]) { + name = fastargs[2]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (fastargs[3]) { + defaults = fastargs[3]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + closure = fastargs[4]; +skip_optional_pos: return_value = func_new_impl(type, code, globals, name, defaults, closure); exit: return return_value; } -/*[clinic end generated code: output=a6ab29e4dd33010a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1d01072cd5620d7e input=a9049054013a1b77]*/ diff --git a/Objects/clinic/listobject.c.h b/Objects/clinic/listobject.c.h index 447cdef..7b8e2d9 100644 --- a/Objects/clinic/listobject.c.h +++ b/Objects/clinic/listobject.c.h @@ -169,14 +169,35 @@ list_sort(PyListObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "reverse", NULL}; - static _PyArg_Parser _parser = {"|$Oi:sort", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sort", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *keyfunc = Py_None; int reverse = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &keyfunc, &reverse)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (args[0]) { + keyfunc = args[0]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + reverse = _PyLong_AsInt(args[1]); + if (reverse == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_kwonly: return_value = list_sort_impl(self, keyfunc, reverse); exit: @@ -338,4 +359,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored)) { return list___reversed___impl(self); } -/*[clinic end generated code: output=4a835f9880a72273 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d1d5078edb7d3cf4 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h index 6770023..453edba 100644 --- a/Objects/clinic/longobject.c.h +++ b/Objects/clinic/longobject.c.h @@ -10,14 +10,29 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "base", NULL}; - static _PyArg_Parser _parser = {"|OO:int", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "int", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; PyObject *x = NULL; PyObject *obase = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &x, &obase)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (nargs < 1) { + goto skip_optional_posonly; + } + noptargs--; + x = fastargs[0]; +skip_optional_posonly: + if (!noptargs) { + goto skip_optional_pos; + } + obase = fastargs[1]; +skip_optional_pos: return_value = long_new_impl(type, x, obase); exit: @@ -183,15 +198,50 @@ int_to_bytes(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject * { PyObject *return_value = NULL; static const char * const _keywords[] = {"length", "byteorder", "signed", NULL}; - static _PyArg_Parser _parser = {"nU|$p:to_bytes", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "to_bytes", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; Py_ssize_t length; PyObject *byteorder; int is_signed = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &length, &byteorder, &is_signed)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + length = ival; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("to_bytes", 2, "str", args[1]); goto exit; } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + byteorder = args[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + is_signed = PyObject_IsTrue(args[2]); + if (is_signed < 0) { + goto exit; + } +skip_optional_kwonly: return_value = int_to_bytes_impl(self, length, byteorder, is_signed); exit: @@ -230,18 +280,37 @@ int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"bytes", "byteorder", "signed", NULL}; - static _PyArg_Parser _parser = {"OU|$p:from_bytes", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "from_bytes", 0}; + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; PyObject *bytes_obj; PyObject *byteorder; int is_signed = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &bytes_obj, &byteorder, &is_signed)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + bytes_obj = args[0]; + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("from_bytes", 2, "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + byteorder = args[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + is_signed = PyObject_IsTrue(args[2]); + if (is_signed < 0) { goto exit; } +skip_optional_kwonly: return_value = int_from_bytes_impl(type, bytes_obj, byteorder, is_signed); exit: return return_value; } -/*[clinic end generated code: output=3b91cda9d83abaa2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=709503897c55bca1 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/moduleobject.c.h b/Objects/clinic/moduleobject.c.h index e841e76..512edee 100644 --- a/Objects/clinic/moduleobject.c.h +++ b/Objects/clinic/moduleobject.c.h @@ -18,17 +18,34 @@ module___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; static const char * const _keywords[] = {"name", "doc", NULL}; - static _PyArg_Parser _parser = {"U|O:module", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "module", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *name; PyObject *doc = Py_None; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &name, &doc)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("module", 1, "str", fastargs[0]); + goto exit; + } + if (PyUnicode_READY(fastargs[0]) == -1) { + goto exit; + } + name = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + doc = fastargs[1]; +skip_optional_pos: return_value = module___init___impl((PyModuleObject *)self, name, doc); exit: return return_value; } -/*[clinic end generated code: output=7b1b324bf6a590d1 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d7b7ca1237597b08 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/odictobject.c.h b/Objects/clinic/odictobject.c.h index 1aea36e..f43bc14 100644 --- a/Objects/clinic/odictobject.c.h +++ b/Objects/clinic/odictobject.c.h @@ -19,14 +19,22 @@ OrderedDict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"iterable", "value", NULL}; - static _PyArg_Parser _parser = {"O|O:fromkeys", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "fromkeys", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *seq; PyObject *value = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &seq, &value)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + seq = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + value = args[1]; +skip_optional_pos: return_value = OrderedDict_fromkeys_impl(type, seq, value); exit: @@ -53,14 +61,22 @@ OrderedDict_setdefault(PyODictObject *self, PyObject *const *args, Py_ssize_t na { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "default", NULL}; - static _PyArg_Parser _parser = {"O|O:setdefault", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "setdefault", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *key; PyObject *default_value = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &key, &default_value)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + key = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + default_value = args[1]; +skip_optional_pos: return_value = OrderedDict_setdefault_impl(self, key, default_value); exit: @@ -86,13 +102,23 @@ OrderedDict_popitem(PyODictObject *self, PyObject *const *args, Py_ssize_t nargs { PyObject *return_value = NULL; static const char * const _keywords[] = {"last", NULL}; - static _PyArg_Parser _parser = {"|p:popitem", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "popitem", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int last = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &last)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + last = PyObject_IsTrue(args[0]); + if (last < 0) { goto exit; } +skip_optional_pos: return_value = OrderedDict_popitem_impl(self, last); exit: @@ -118,17 +144,28 @@ OrderedDict_move_to_end(PyODictObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "last", NULL}; - static _PyArg_Parser _parser = {"O|p:move_to_end", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "move_to_end", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *key; int last = 1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &key, &last)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { + goto exit; + } + key = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + last = PyObject_IsTrue(args[1]); + if (last < 0) { goto exit; } +skip_optional_pos: return_value = OrderedDict_move_to_end_impl(self, key, last); exit: return return_value; } -/*[clinic end generated code: output=f6f189e1fe032e0b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=8eb1296df9142908 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/structseq.c.h b/Objects/clinic/structseq.c.h index ed6a564..b3b4836 100644 --- a/Objects/clinic/structseq.c.h +++ b/Objects/clinic/structseq.c.h @@ -10,17 +10,27 @@ structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"sequence", "dict", NULL}; - static _PyArg_Parser _parser = {"O|O:structseq", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "structseq", 0}; + PyObject *argsbuf[2]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; PyObject *arg; PyObject *dict = NULL; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &arg, &dict)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); + if (!fastargs) { goto exit; } + arg = fastargs[0]; + if (!noptargs) { + goto skip_optional_pos; + } + dict = fastargs[1]; +skip_optional_pos: return_value = structseq_new_impl(type, arg, dict); exit: return return_value; } -/*[clinic end generated code: output=cd643eb89b5d312a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ed3019acf49b656c input=a9049054013a1b77]*/ diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index 3e40a62..647507d 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -142,14 +142,51 @@ unicode_encode(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"encoding", "errors", NULL}; - static _PyArg_Parser _parser = {"|ss:encode", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &encoding, &errors)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + if (!PyUnicode_Check(args[0])) { + _PyArg_BadArgument("encode", 1, "str", args[0]); + goto exit; + } + Py_ssize_t encoding_length; + encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length); + if (encoding == NULL) { + goto exit; + } + if (strlen(encoding) != (size_t)encoding_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("encode", 2, "str", args[1]); + goto exit; + } + Py_ssize_t errors_length; + errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length); + if (errors == NULL) { + goto exit; + } + if (strlen(errors) != (size_t)errors_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } +skip_optional_pos: return_value = unicode_encode_impl(self, encoding, errors); exit: @@ -175,13 +212,28 @@ unicode_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"tabsize", NULL}; - static _PyArg_Parser _parser = {"|i:expandtabs", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "expandtabs", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int tabsize = 8; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &tabsize)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + tabsize = _PyLong_AsInt(args[0]); + if (tabsize == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = unicode_expandtabs_impl(self, tabsize); exit: @@ -781,14 +833,43 @@ unicode_split(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"|On:split", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "split", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sep, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); goto exit; } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = unicode_split_impl(self, sep, maxsplit); exit: @@ -854,14 +935,43 @@ unicode_rsplit(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"sep", "maxsplit", NULL}; - static _PyArg_Parser _parser = {"|On:rsplit", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sep, &maxsplit)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[0]) { + sep = args[0]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[1]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsplit = ival; + } +skip_optional_pos: return_value = unicode_rsplit_impl(self, sep, maxsplit); exit: @@ -888,13 +998,28 @@ unicode_splitlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"keepends", NULL}; - static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int keepends = 0; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &keepends)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + keepends = _PyLong_AsInt(args[0]); + if (keepends == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = unicode_splitlines_impl(self, keepends); exit: @@ -1107,4 +1232,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored)) { return unicode_sizeof_impl(self); } -/*[clinic end generated code: output=087ff163a10505ae input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d1541724cb4a0070 input=a9049054013a1b77]*/ diff --git a/Objects/stringlib/clinic/transmogrify.h.h b/Objects/stringlib/clinic/transmogrify.h.h index 15c43af..0c53a75 100644 --- a/Objects/stringlib/clinic/transmogrify.h.h +++ b/Objects/stringlib/clinic/transmogrify.h.h @@ -21,13 +21,28 @@ stringlib_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"tabsize", NULL}; - static _PyArg_Parser _parser = {"|i:expandtabs", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "expandtabs", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int tabsize = 8; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &tabsize)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { goto exit; } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + tabsize = _PyLong_AsInt(args[0]); + if (tabsize == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = stringlib_expandtabs_impl(self, tabsize); exit: @@ -259,4 +274,4 @@ stringlib_zfill(PyObject *self, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=787248a980f6a00e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=96cbb19b238d0e84 input=a9049054013a1b77]*/ diff --git a/PC/clinic/_testconsole.c.h b/PC/clinic/_testconsole.c.h index 2809f2a..a37d123 100644 --- a/PC/clinic/_testconsole.c.h +++ b/PC/clinic/_testconsole.c.h @@ -22,14 +22,21 @@ _testconsole_write_input(PyObject *module, PyObject *const *args, Py_ssize_t nar { PyObject *return_value = NULL; static const char * const _keywords[] = {"file", "s", NULL}; - static _PyArg_Parser _parser = {"OS:write_input", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "write_input", 0}; + PyObject *argsbuf[2]; PyObject *file; PyBytesObject *s; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &file, &s)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { goto exit; } + file = args[0]; + if (!PyBytes_Check(args[1])) { + _PyArg_BadArgument("write_input", 2, "bytes", args[1]); + goto exit; + } + s = (PyBytesObject *)args[1]; return_value = _testconsole_write_input_impl(module, file, s); exit: @@ -57,13 +64,15 @@ _testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nar { PyObject *return_value = NULL; static const char * const _keywords[] = {"file", NULL}; - static _PyArg_Parser _parser = {"O:read_output", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "read_output", 0}; + PyObject *argsbuf[1]; PyObject *file; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &file)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } + file = args[0]; return_value = _testconsole_read_output_impl(module, file); exit: @@ -79,4 +88,4 @@ exit: #ifndef _TESTCONSOLE_READ_OUTPUT_METHODDEF #define _TESTCONSOLE_READ_OUTPUT_METHODDEF #endif /* !defined(_TESTCONSOLE_READ_OUTPUT_METHODDEF) */ -/*[clinic end generated code: output=ab9ea8e78d26288e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ef452d5fb9287fc2 input=a9049054013a1b77]*/ diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index 21a9302..5021025 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -88,15 +88,19 @@ winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t n { PyObject *return_value = NULL; static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL}; - static _PyArg_Parser _parser = {"OOO:__exit__", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "__exit__", 0}; + PyObject *argsbuf[3]; PyObject *exc_type; PyObject *exc_value; PyObject *traceback; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &exc_type, &exc_value, &traceback)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); + if (!args) { goto exit; } + exc_type = args[0]; + exc_value = args[1]; + traceback = args[2]; return_value = winreg_HKEYType___exit___impl(self, exc_type, exc_value, traceback); exit: @@ -1117,4 +1121,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=bd491131d343ae7a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1204d20c543b5b4a input=a9049054013a1b77]*/ diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index 86514f5..b37db4c 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -24,12 +24,23 @@ winsound_PlaySound(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py { PyObject *return_value = NULL; static const char * const _keywords[] = {"sound", "flags", NULL}; - static _PyArg_Parser _parser = {"Oi:PlaySound", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "PlaySound", 0}; + PyObject *argsbuf[2]; PyObject *sound; int flags; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &sound, &flags)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + sound = args[0]; + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[1]); + if (flags == -1 && PyErr_Occurred()) { goto exit; } return_value = winsound_PlaySound_impl(module, sound, flags); @@ -61,12 +72,31 @@ winsound_Beep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"frequency", "duration", NULL}; - static _PyArg_Parser _parser = {"ii:Beep", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "Beep", 0}; + PyObject *argsbuf[2]; int frequency; int duration; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &frequency, &duration)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + frequency = _PyLong_AsInt(args[0]); + if (frequency == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(args[1])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + duration = _PyLong_AsInt(args[1]); + if (duration == -1 && PyErr_Occurred()) { goto exit; } return_value = winsound_Beep_impl(module, frequency, duration); @@ -94,16 +124,31 @@ winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, { PyObject *return_value = NULL; static const char * const _keywords[] = {"type", NULL}; - static _PyArg_Parser _parser = {"|i:MessageBeep", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "MessageBeep", 0}; + PyObject *argsbuf[1]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; int type = MB_OK; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &type)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + type = _PyLong_AsInt(args[0]); + if (type == -1 && PyErr_Occurred()) { goto exit; } +skip_optional_pos: return_value = winsound_MessageBeep_impl(module, type); exit: return return_value; } -/*[clinic end generated code: output=19e5f0fb15bcd5bc input=a9049054013a1b77]*/ +/*[clinic end generated code: output=28d1cd033282723d input=a9049054013a1b77]*/ diff --git a/Python/clinic/_warnings.c.h b/Python/clinic/_warnings.c.h index d1e50de..67ab0e3 100644 --- a/Python/clinic/_warnings.c.h +++ b/Python/clinic/_warnings.c.h @@ -20,19 +20,55 @@ warnings_warn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"message", "category", "stacklevel", "source", NULL}; - static _PyArg_Parser _parser = {"O|OnO:warn", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "warn", 0}; + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *message; PyObject *category = Py_None; Py_ssize_t stacklevel = 1; PyObject *source = Py_None; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &message, &category, &stacklevel, &source)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); + if (!args) { goto exit; } + message = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + category = args[1]; + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[2]) { + if (PyFloat_Check(args[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = PyNumber_Index(args[2]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + stacklevel = ival; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + source = args[3]; +skip_optional_pos: return_value = warnings_warn_impl(module, message, category, stacklevel, source); exit: return return_value; } -/*[clinic end generated code: output=a4fbe6e2d1cc2091 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b7bb54c73b5433ec input=a9049054013a1b77]*/ diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index df99709..0ed11bc 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -180,7 +180,9 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj { PyObject *return_value = NULL; static const char * const _keywords[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", "feature_version", NULL}; - static _PyArg_Parser _parser = {"OO&s|iiii:compile", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "compile", 0}; + PyObject *argsbuf[7]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; PyObject *source; PyObject *filename; const char *mode; @@ -189,10 +191,82 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj int optimize = -1; int feature_version = -1; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize, &feature_version)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 7, 0, argsbuf); + if (!args) { goto exit; } + source = args[0]; + if (!PyUnicode_FSDecoder(args[1], &filename)) { + goto exit; + } + if (!PyUnicode_Check(args[2])) { + _PyArg_BadArgument("compile", 3, "str", args[2]); + goto exit; + } + Py_ssize_t mode_length; + mode = PyUnicode_AsUTF8AndSize(args[2], &mode_length); + if (mode == NULL) { + goto exit; + } + if (strlen(mode) != (size_t)mode_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[3]) { + if (PyFloat_Check(args[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + flags = _PyLong_AsInt(args[3]); + if (flags == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[4]) { + if (PyFloat_Check(args[4])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + dont_inherit = _PyLong_AsInt(args[4]); + if (dont_inherit == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (args[5]) { + if (PyFloat_Check(args[5])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + optimize = _PyLong_AsInt(args[5]); + if (optimize == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + if (PyFloat_Check(args[6])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + feature_version = _PyLong_AsInt(args[6]); + if (feature_version == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize, feature_version); exit: @@ -637,14 +711,22 @@ builtin_round(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec { PyObject *return_value = NULL; static const char * const _keywords[] = {"number", "ndigits", NULL}; - static _PyArg_Parser _parser = {"O|O:round", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "round", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *number; PyObject *ndigits = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &number, &ndigits)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + number = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + ndigits = args[1]; +skip_optional_pos: return_value = builtin_round_impl(module, number, ndigits); exit: @@ -672,14 +754,22 @@ builtin_sum(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject { PyObject *return_value = NULL; static const char * const _keywords[] = {"", "start", NULL}; - static _PyArg_Parser _parser = {"O|O:sum", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "sum", 0}; + PyObject *argsbuf[2]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; PyObject *iterable; PyObject *start = NULL; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &iterable, &start)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); + if (!args) { goto exit; } + iterable = args[0]; + if (!noptargs) { + goto skip_optional_pos; + } + start = args[1]; +skip_optional_pos: return_value = builtin_sum_impl(module, iterable, start); exit: @@ -755,4 +845,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=00b97a48ea49eaf2 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3f690311ac556c31 input=a9049054013a1b77]*/ diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h index 9ee20fb..05e3106 100644 --- a/Python/clinic/import.c.h +++ b/Python/clinic/import.c.h @@ -411,12 +411,29 @@ _imp_source_hash(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb { PyObject *return_value = NULL; static const char * const _keywords[] = {"key", "source", NULL}; - static _PyArg_Parser _parser = {"ly*:source_hash", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "source_hash", 0}; + PyObject *argsbuf[2]; long key; Py_buffer source = {NULL, NULL}; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &key, &source)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + key = PyLong_AsLong(args[0]); + if (key == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyObject_GetBuffer(args[1], &source, PyBUF_SIMPLE) != 0) { + goto exit; + } + if (!PyBuffer_IsContiguous(&source, 'C')) { + _PyArg_BadArgument("source_hash", 2, "contiguous buffer", args[1]); goto exit; } return_value = _imp_source_hash_impl(module, key, &source); @@ -437,4 +454,4 @@ exit: #ifndef _IMP_EXEC_DYNAMIC_METHODDEF #define _IMP_EXEC_DYNAMIC_METHODDEF #endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */ -/*[clinic end generated code: output=2409b8feeafe7c4b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b51244770fdcf4b8 input=a9049054013a1b77]*/ diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h index fc9794b..c70b721 100644 --- a/Python/clinic/sysmodule.c.h +++ b/Python/clinic/sysmodule.c.h @@ -410,11 +410,21 @@ sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, { PyObject *return_value = NULL; static const char * const _keywords[] = {"depth", NULL}; - static _PyArg_Parser _parser = {"i:set_coroutine_origin_tracking_depth", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "set_coroutine_origin_tracking_depth", 0}; + PyObject *argsbuf[1]; int depth; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &depth)) { + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + if (PyFloat_Check(args[0])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + depth = _PyLong_AsInt(args[0]); + if (depth == -1 && PyErr_Occurred()) { goto exit; } return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth); @@ -1050,4 +1060,4 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored)) #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ -/*[clinic end generated code: output=109787af3401cd27 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3ba4c194d00f1866 input=a9049054013a1b77]*/ diff --git a/Python/clinic/traceback.c.h b/Python/clinic/traceback.c.h index d9daccb..2815f65 100644 --- a/Python/clinic/traceback.c.h +++ b/Python/clinic/traceback.c.h @@ -17,14 +17,41 @@ tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static const char * const _keywords[] = {"tb_next", "tb_frame", "tb_lasti", "tb_lineno", NULL}; - static _PyArg_Parser _parser = {"OO!ii:TracebackType", _keywords, 0}; + static _PyArg_Parser _parser = {NULL, _keywords, "TracebackType", 0}; + PyObject *argsbuf[4]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); PyObject *tb_next; PyFrameObject *tb_frame; int tb_lasti; int tb_lineno; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &tb_next, &PyFrame_Type, &tb_frame, &tb_lasti, &tb_lineno)) { + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 4, 4, 0, argsbuf); + if (!fastargs) { + goto exit; + } + tb_next = fastargs[0]; + if (!PyObject_TypeCheck(fastargs[1], &PyFrame_Type)) { + _PyArg_BadArgument("TracebackType", 2, (&PyFrame_Type)->tp_name, fastargs[1]); + goto exit; + } + tb_frame = (PyFrameObject *)fastargs[1]; + if (PyFloat_Check(fastargs[2])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + tb_lasti = _PyLong_AsInt(fastargs[2]); + if (tb_lasti == -1 && PyErr_Occurred()) { + goto exit; + } + if (PyFloat_Check(fastargs[3])) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + tb_lineno = _PyLong_AsInt(fastargs[3]); + if (tb_lineno == -1 && PyErr_Occurred()) { goto exit; } return_value = tb_new_impl(type, tb_next, tb_frame, tb_lasti, tb_lineno); @@ -32,4 +59,4 @@ tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=0133130d7d19556f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=7e4c0e252d0973b0 input=a9049054013a1b77]*/ diff --git a/Python/getargs.c b/Python/getargs.c index 05ebe9c..693a29c 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1905,24 +1905,11 @@ parser_init(struct _PyArg_Parser *parser) int i, len, min, max, nkw; PyObject *kwtuple; - assert(parser->format != NULL); assert(parser->keywords != NULL); if (parser->kwtuple != NULL) { return 1; } - /* grab the function name or custom error msg first (mutually exclusive) */ - parser->fname = strchr(parser->format, ':'); - if (parser->fname) { - parser->fname++; - parser->custom_msg = NULL; - } - else { - parser->custom_msg = strchr(parser->format,';'); - if (parser->custom_msg) - parser->custom_msg++; - } - keywords = parser->keywords; /* scan keywords and count the number of positional-only parameters */ for (i = 0; keywords[i] && !*keywords[i]; i++) { @@ -1938,60 +1925,74 @@ parser_init(struct _PyArg_Parser *parser) } len = i; - min = max = INT_MAX; format = parser->format; - for (i = 0; i < len; i++) { - if (*format == '|') { - if (min != INT_MAX) { - PyErr_SetString(PyExc_SystemError, - "Invalid format string (| specified twice)"); - return 0; + if (format) { + /* grab the function name or custom error msg first (mutually exclusive) */ + parser->fname = strchr(parser->format, ':'); + if (parser->fname) { + parser->fname++; + parser->custom_msg = NULL; + } + else { + parser->custom_msg = strchr(parser->format,';'); + if (parser->custom_msg) + parser->custom_msg++; + } + + min = max = INT_MAX; + for (i = 0; i < len; i++) { + if (*format == '|') { + if (min != INT_MAX) { + PyErr_SetString(PyExc_SystemError, + "Invalid format string (| specified twice)"); + return 0; + } + if (max != INT_MAX) { + PyErr_SetString(PyExc_SystemError, + "Invalid format string ($ before |)"); + return 0; + } + min = i; + format++; } - if (max != INT_MAX) { - PyErr_SetString(PyExc_SystemError, - "Invalid format string ($ before |)"); - return 0; + if (*format == '$') { + if (max != INT_MAX) { + PyErr_SetString(PyExc_SystemError, + "Invalid format string ($ specified twice)"); + return 0; + } + if (i < parser->pos) { + PyErr_SetString(PyExc_SystemError, + "Empty parameter name after $"); + return 0; + } + max = i; + format++; } - min = i; - format++; - } - if (*format == '$') { - if (max != INT_MAX) { - PyErr_SetString(PyExc_SystemError, - "Invalid format string ($ specified twice)"); + if (IS_END_OF_FORMAT(*format)) { + PyErr_Format(PyExc_SystemError, + "More keyword list entries (%d) than " + "format specifiers (%d)", len, i); return 0; } - if (i < parser->pos) { - PyErr_SetString(PyExc_SystemError, - "Empty parameter name after $"); + + msg = skipitem(&format, NULL, 0); + if (msg) { + PyErr_Format(PyExc_SystemError, "%s: '%s'", msg, + format); return 0; } - max = i; - format++; - } - if (IS_END_OF_FORMAT(*format)) { - PyErr_Format(PyExc_SystemError, - "More keyword list entries (%d) than " - "format specifiers (%d)", len, i); - return 0; } + parser->min = Py_MIN(min, len); + parser->max = Py_MIN(max, len); - msg = skipitem(&format, NULL, 0); - if (msg) { - PyErr_Format(PyExc_SystemError, "%s: '%s'", msg, - format); + if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) { + PyErr_Format(PyExc_SystemError, + "more argument specifiers than keyword list entries " + "(remaining format:'%s')", format); return 0; } } - parser->min = Py_MIN(min, len); - parser->max = Py_MIN(max, len); - - if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) { - PyErr_Format(PyExc_SystemError, - "more argument specifiers than keyword list entries " - "(remaining format:'%s')", format); - return 0; - } nkw = len - parser->pos; kwtuple = PyTuple_New(nkw); @@ -2313,6 +2314,215 @@ vgetargskeywordsfast(PyObject *args, PyObject *keywords, } +#undef _PyArg_UnpackKeywords + +PyObject * const * +_PyArg_UnpackKeywords(PyObject *const *args, Py_ssize_t nargs, + PyObject *kwargs, PyObject *kwnames, + struct _PyArg_Parser *parser, + int minpos, int maxpos, int minkw, + PyObject **buf) +{ + PyObject *kwtuple; + PyObject *keyword; + int i, posonly, minposonly, maxargs; + int reqlimit = minkw ? maxpos + minkw : minpos; + Py_ssize_t nkwargs; + PyObject *current_arg; + PyObject * const *kwstack = NULL; + + assert(kwargs == NULL || PyDict_Check(kwargs)); + assert(kwargs == NULL || kwnames == NULL); + + if (parser == NULL) { + PyErr_BadInternalCall(); + return NULL; + } + + if (kwnames != NULL && !PyTuple_Check(kwnames)) { + PyErr_BadInternalCall(); + return NULL; + } + + if (args == NULL && nargs == 0) { + args = buf; + } + + if (!parser_init(parser)) { + return NULL; + } + + kwtuple = parser->kwtuple; + posonly = parser->pos; + minposonly = Py_MIN(posonly, minpos); + maxargs = posonly + (int)PyTuple_GET_SIZE(kwtuple); + + if (kwargs != NULL) { + nkwargs = PyDict_GET_SIZE(kwargs); + } + else if (kwnames != NULL) { + nkwargs = PyTuple_GET_SIZE(kwnames); + kwstack = args + nargs; + } + else { + nkwargs = 0; + } + if (nkwargs == 0 && minkw == 0 && minpos <= nargs && nargs <= maxpos) { + /* Fast path. */ + return args; + } + if (nargs + nkwargs > maxargs) { + /* Adding "keyword" (when nargs == 0) prevents producing wrong error + messages in some special cases (see bpo-31229). */ + PyErr_Format(PyExc_TypeError, + "%.200s%s takes at most %d %sargument%s (%zd given)", + (parser->fname == NULL) ? "function" : parser->fname, + (parser->fname == NULL) ? "" : "()", + maxargs, + (nargs == 0) ? "keyword " : "", + (maxargs == 1) ? "" : "s", + nargs + nkwargs); + return NULL; + } + if (nargs > maxpos) { + if (maxpos == 0) { + PyErr_Format(PyExc_TypeError, + "%.200s%s takes no positional arguments", + (parser->fname == NULL) ? "function" : parser->fname, + (parser->fname == NULL) ? "" : "()"); + } + else { + PyErr_Format(PyExc_TypeError, + "%.200s%s takes %s %d positional argument%s (%zd given)", + (parser->fname == NULL) ? "function" : parser->fname, + (parser->fname == NULL) ? "" : "()", + (minpos < maxpos) ? "at most" : "exactly", + maxpos, + (maxpos == 1) ? "" : "s", + nargs); + } + return NULL; + } + if (nargs < minposonly) { + PyErr_Format(PyExc_TypeError, + "%.200s%s takes %s %d positional argument%s" + " (%zd given)", + (parser->fname == NULL) ? "function" : parser->fname, + (parser->fname == NULL) ? "" : "()", + minposonly < maxpos ? "at least" : "exactly", + minposonly, + minposonly == 1 ? "" : "s", + nargs); + return NULL; + } + + /* copy tuple args */ + for (i = 0; i < nargs; i++) { + buf[i] = args[i]; + } + + /* copy keyword args using kwtuple to drive process */ + for (i = Py_MAX(nargs, posonly); i < maxargs; i++) { + if (nkwargs) { + keyword = PyTuple_GET_ITEM(kwtuple, i - posonly); + if (kwargs != NULL) { + current_arg = PyDict_GetItemWithError(kwargs, keyword); + if (!current_arg && PyErr_Occurred()) { + return NULL; + } + } + else { + current_arg = find_keyword(kwnames, kwstack, keyword); + } + } + else if (i >= reqlimit) { + break; + } + else { + current_arg = NULL; + } + + buf[i] = current_arg; + + if (current_arg) { + --nkwargs; + } + else if (i < minpos || (maxpos <= i && i < reqlimit)) { + /* Less arguments than required */ + keyword = PyTuple_GET_ITEM(kwtuple, i - posonly); + PyErr_Format(PyExc_TypeError, "%.200s%s missing required " + "argument '%U' (pos %d)", + (parser->fname == NULL) ? "function" : parser->fname, + (parser->fname == NULL) ? "" : "()", + keyword, i+1); + return NULL; + } + } + + if (nkwargs > 0) { + Py_ssize_t j; + /* make sure there are no arguments given by name and position */ + for (i = posonly; i < nargs; i++) { + keyword = PyTuple_GET_ITEM(kwtuple, i - posonly); + if (kwargs != NULL) { + current_arg = PyDict_GetItemWithError(kwargs, keyword); + if (!current_arg && PyErr_Occurred()) { + return NULL; + } + } + else { + current_arg = find_keyword(kwnames, kwstack, keyword); + } + if (current_arg) { + /* arg present in tuple and in dict */ + PyErr_Format(PyExc_TypeError, + "argument for %.200s%s given by name ('%U') " + "and position (%d)", + (parser->fname == NULL) ? "function" : parser->fname, + (parser->fname == NULL) ? "" : "()", + keyword, i+1); + return NULL; + } + } + /* make sure there are no extraneous keyword arguments */ + j = 0; + while (1) { + int match; + if (kwargs != NULL) { + if (!PyDict_Next(kwargs, &j, &keyword, NULL)) + break; + } + else { + if (j >= PyTuple_GET_SIZE(kwnames)) + break; + keyword = PyTuple_GET_ITEM(kwnames, j); + j++; + } + + if (!PyUnicode_Check(keyword)) { + PyErr_SetString(PyExc_TypeError, + "keywords must be strings"); + return NULL; + } + match = PySequence_Contains(kwtuple, keyword); + if (match <= 0) { + if (!match) { + PyErr_Format(PyExc_TypeError, + "'%U' is an invalid keyword " + "argument for %.200s%s", + keyword, + (parser->fname == NULL) ? "this function" : parser->fname, + (parser->fname == NULL) ? "" : "()"); + } + return NULL; + } + } + } + + return buf; +} + + static const char * skipitem(const char **p_format, va_list *p_va, int flags) { diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 0e7ce96..cb2ded4 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -645,10 +645,21 @@ class CLanguage(Language): default_return_converter = (not f.return_converter or f.return_converter.type == 'PyObject *') - positional = parameters and parameters[-1].is_positional_only() - new_or_init = f.kind in (METHOD_NEW, METHOD_INIT) + pos_only = min_pos = max_pos = min_kw_only = 0 + for i, p in enumerate(parameters, 1): + if p.is_keyword_only(): + assert not p.is_positional_only() + if not p.is_optional(): + min_kw_only = i - max_pos + else: + max_pos = i + if p.is_positional_only(): + pos_only = i + if not p.is_optional(): + min_pos = i + meth_o = (len(parameters) == 1 and parameters[0].is_positional_only() and not converters[0].is_optional() and @@ -712,16 +723,19 @@ class CLanguage(Language): # parser_body_fields remembers the fields passed in to the # previous call to parser_body. this is used for an awful hack. parser_body_fields = () - def parser_body(prototype, *fields): - nonlocal parser_body_fields + parser_body_declarations = '' + def parser_body(prototype, *fields, declarations=''): + nonlocal parser_body_fields, parser_body_declarations add, output = text_accumulator() add(prototype) parser_body_fields = fields + parser_body_declarations = declarations fields = list(fields) fields.insert(0, normalize_snippet(""" {{ {return_value_declaration} + {parser_declarations} {declarations} {initializers} """) + "\n") @@ -739,13 +753,7 @@ class CLanguage(Language): for field in fields: add('\n') add(field) - return output() - - def insert_keywords(s): - return linear_format(s, declarations= - 'static const char * const _keywords[] = {{{keywords}, NULL}};\n' - 'static _PyArg_Parser _parser = {{"{format_units}:{name}", _keywords, 0}};\n' - '{declarations}') + return linear_format(output(), parser_declarations=declarations) if not parameters: # no parameters, METH_NOARGS @@ -818,7 +826,7 @@ class CLanguage(Language): parser_definition = parser_body(parser_prototype, ' {option_group_parsing}') - elif positional: + elif pos_only == len(parameters): if not new_or_init: # positional-only, but no option groups # we only need one call to _PyArg_ParseStack @@ -836,15 +844,19 @@ class CLanguage(Language): nargs = 'PyTuple_GET_SIZE(args)' argname_fmt = 'PyTuple_GET_ITEM(args, %d)' - parser_code = [] + parser_code = [normalize_snippet(""" + if (!_PyArg_CheckPositional("{name}", %s, %d, %d)) {{ + goto exit; + }} + """ % (nargs, min_pos, max_pos), indent=4)] has_optional = False - for i, converter in enumerate(converters): - parsearg = converter.parse_arg(argname_fmt % i, i + 1) + for i, p in enumerate(parameters): + parsearg = p.converter.parse_arg(argname_fmt % i, i + 1) if parsearg is None: - #print('Cannot convert %s %r for %s' % (converter.__class__.__name__, converter.format_unit, converter.name), file=sys.stderr) + #print('Cannot convert %s %r for %s' % (p.converter.__class__.__name__, p.converter.format_unit, p.converter.name), file=sys.stderr) parser_code = None break - if has_optional or converter.default is not unspecified: + if has_optional or p.is_optional(): has_optional = True parser_code.append(normalize_snippet(""" if (%s < %d) {{ @@ -854,11 +866,6 @@ class CLanguage(Language): parser_code.append(normalize_snippet(parsearg, indent=4)) if parser_code is not None: - parser_code.insert(0, normalize_snippet(""" - if (!_PyArg_CheckPositional("{name}", %s, {unpack_min}, {unpack_max})) {{ - goto exit; - }} - """ % nargs, indent=4)) if has_optional: parser_code.append("skip_optional:") else: @@ -878,33 +885,122 @@ class CLanguage(Language): """, indent=4)] parser_definition = parser_body(parser_prototype, *parser_code) - elif not new_or_init: - flags = "METH_FASTCALL|METH_KEYWORDS" - - parser_prototype = parser_prototype_fastcall_keywords - - body = normalize_snippet(""" - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - {parse_arguments})) {{ - goto exit; - }} - """, indent=4) - parser_definition = parser_body(parser_prototype, body) - parser_definition = insert_keywords(parser_definition) else: - # positional-or-keyword arguments - flags = "METH_VARARGS|METH_KEYWORDS" + has_optional_kw = (max(pos_only, min_pos) + min_kw_only < len(converters)) + if not new_or_init: + flags = "METH_FASTCALL|METH_KEYWORDS" + parser_prototype = parser_prototype_fastcall_keywords + argname_fmt = 'args[%d]' + declarations = normalize_snippet(""" + static const char * const _keywords[] = {{{keywords}, NULL}}; + static _PyArg_Parser _parser = {{NULL, _keywords, "{name}", 0}}; + PyObject *argsbuf[%s]; + """ % len(converters)) + if has_optional_kw: + declarations += "\nPy_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - %d;" % (min_pos + min_kw_only) + parser_code = [normalize_snippet(""" + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, %d, %d, %d, argsbuf); + if (!args) {{ + goto exit; + }} + """ % (min_pos, max_pos, min_kw_only), indent=4)] + else: + # positional-or-keyword arguments + flags = "METH_VARARGS|METH_KEYWORDS" + parser_prototype = parser_prototype_keyword + argname_fmt = 'fastargs[%d]' + declarations = normalize_snippet(""" + static const char * const _keywords[] = {{{keywords}, NULL}}; + static _PyArg_Parser _parser = {{NULL, _keywords, "{name}", 0}}; + PyObject *argsbuf[%s]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + """ % len(converters)) + if has_optional_kw: + declarations += "\nPy_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - %d;" % (min_pos + min_kw_only) + parser_code = [normalize_snippet(""" + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, %d, %d, %d, argsbuf); + if (!fastargs) {{ + goto exit; + }} + """ % (min_pos, max_pos, min_kw_only), indent=4)] - parser_prototype = parser_prototype_keyword + add_label = None + for i, p in enumerate(parameters): + parsearg = p.converter.parse_arg(argname_fmt % i, i + 1) + if parsearg is None: + #print('Cannot convert %s %r for %s' % (p.converter.__class__.__name__, p.converter.format_unit, p.converter.name), file=sys.stderr) + parser_code = None + break + if add_label and (i == pos_only or i == max_pos): + parser_code.append("%s:" % add_label) + add_label = None + if not p.is_optional(): + parser_code.append(normalize_snippet(parsearg, indent=4)) + elif i < pos_only: + add_label = 'skip_optional_posonly' + parser_code.append(normalize_snippet(""" + if (nargs < %d) {{ + goto %s; + }} + """ % (i + 1, add_label), indent=4)) + if has_optional_kw: + parser_code.append(normalize_snippet(""" + noptargs--; + """, indent=4)) + parser_code.append(normalize_snippet(parsearg, indent=4)) + else: + if i < max_pos: + label = 'skip_optional_pos' + first_opt = max(min_pos, pos_only) + else: + label = 'skip_optional_kwonly' + first_opt = max_pos + min_kw_only + if i == first_opt: + add_label = label + parser_code.append(normalize_snippet(""" + if (!noptargs) {{ + goto %s; + }} + """ % add_label, indent=4)) + if i + 1 == len(parameters): + parser_code.append(normalize_snippet(parsearg, indent=4)) + else: + add_label = label + parser_code.append(normalize_snippet(""" + if (%s) {{ + """ % (argname_fmt % i), indent=4)) + parser_code.append(normalize_snippet(parsearg, indent=8)) + parser_code.append(normalize_snippet(""" + if (!--noptargs) {{ + goto %s; + }} + }} + """ % add_label, indent=4)) - body = normalize_snippet(""" - if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - {parse_arguments})) {{ - goto exit; - }} - """, indent=4) - parser_definition = parser_body(parser_prototype, body) - parser_definition = insert_keywords(parser_definition) + if parser_code is not None: + if add_label: + parser_code.append("%s:" % add_label) + else: + declarations = ( + 'static const char * const _keywords[] = {{{keywords}, NULL}};\n' + 'static _PyArg_Parser _parser = {{"{format_units}:{name}", _keywords, 0}};') + if not new_or_init: + parser_code = [normalize_snippet(""" + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + {parse_arguments})) {{ + goto exit; + }} + """, indent=4)] + else: + parser_code = [normalize_snippet(""" + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + {parse_arguments})) {{ + goto exit; + }} + """, indent=4)] + parser_definition = parser_body(parser_prototype, *parser_code, + declarations=declarations) if new_or_init: @@ -938,9 +1034,8 @@ class CLanguage(Language): }} """, indent=4)) - parser_definition = parser_body(parser_prototype, *fields) - if parses_keywords: - parser_definition = insert_keywords(parser_definition) + parser_definition = parser_body(parser_prototype, *fields, + declarations=parser_body_declarations) if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'): @@ -2176,6 +2271,9 @@ class Parameter: def is_positional_only(self): return self.kind == inspect.Parameter.POSITIONAL_ONLY + def is_optional(self): + return (self.default is not unspecified) + def copy(self, **overrides): kwargs = { 'name': self.name, 'kind': self.kind, 'default':self.default, -- cgit v0.12