diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-01-11 14:01:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-11 14:01:14 (GMT) |
commit | 4fa9591025b6a098f3d6402e5413ee6740ede6c5 (patch) | |
tree | a81280fdd40c6a5b8c00613b0a8903624499afc5 /Python/clinic/bltinmodule.c.h | |
parent | 5485085b324a45307c1ff4ec7d85b5998d7d5e0d (diff) | |
download | cpython-4fa9591025b6a098f3d6402e5413ee6740ede6c5.zip cpython-4fa9591025b6a098f3d6402e5413ee6740ede6c5.tar.gz cpython-4fa9591025b6a098f3d6402e5413ee6740ede6c5.tar.bz2 |
bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313)
Diffstat (limited to 'Python/clinic/bltinmodule.c.h')
-rw-r--r-- | Python/clinic/bltinmodule.c.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index 7f043da..68d8dcc 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -94,10 +94,22 @@ builtin_format(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *value; PyObject *format_spec = NULL; - if (!_PyArg_ParseStack(args, nargs, "O|U:format", - &value, &format_spec)) { + if (!_PyArg_CheckPositional("format", nargs, 1, 2)) { goto exit; } + value = args[0]; + if (nargs < 2) { + goto skip_optional; + } + if (!PyUnicode_Check(args[1])) { + _PyArg_BadArgument("format", 2, "str", args[1]); + goto exit; + } + if (PyUnicode_READY(args[1]) == -1) { + goto exit; + } + format_spec = args[1]; +skip_optional: return_value = builtin_format_impl(module, value, format_spec); exit: @@ -717,4 +729,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=ed300ebf3f6db530 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=11b5cd918bd7eb18 input=a9049054013a1b77]*/ |