diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2019-03-14 10:32:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-14 10:32:22 +0200 |
| commit | 3191391515824fa7f3c573d807f1034c6a28fab3 (patch) | |
| tree | ff8213b07b206de4df88dc352ee957ce68f0f2de /Modules/clinic/_opcode.c.h | |
| parent | 2c0d3f454705bb5ccf5f6189f3cf77bbae4f056b (diff) | |
| download | cpython-git-3191391515824fa7f3c573d807f1034c6a28fab3.tar.gz | |
bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-12058)
Diffstat (limited to 'Modules/clinic/_opcode.c.h')
| -rw-r--r-- | Modules/clinic/_opcode.c.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/Modules/clinic/_opcode.c.h b/Modules/clinic/_opcode.c.h index 2104a52915..777701ff14 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]*/ |
