bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-12058)
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 @@
{
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 @@
exit:
return return_value;
}
-/*[clinic end generated code: output=787248a980f6a00e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=96cbb19b238d0e84 input=a9049054013a1b77]*/