diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-03-14 08:32:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-14 08:32:22 (GMT) |
commit | 3191391515824fa7f3c573d807f1034c6a28fab3 (patch) | |
tree | ff8213b07b206de4df88dc352ee957ce68f0f2de /Objects/clinic/enumobject.c.h | |
parent | 2c0d3f454705bb5ccf5f6189f3cf77bbae4f056b (diff) | |
download | cpython-3191391515824fa7f3c573d807f1034c6a28fab3.zip cpython-3191391515824fa7f3c573d807f1034c6a28fab3.tar.gz cpython-3191391515824fa7f3c573d807f1034c6a28fab3.tar.bz2 |
bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-12058)
Diffstat (limited to 'Objects/clinic/enumobject.c.h')
-rw-r--r-- | Objects/clinic/enumobject.c.h | 18 |
1 files changed, 14 insertions, 4 deletions
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]*/ |