bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)

This commit is contained in:
Serhiy Storchaka 2018-12-25 13:23:47 +02:00 committed by GitHub
parent 65ce60aef1
commit 32d96a2b5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 1677 additions and 275 deletions

View file

@ -228,7 +228,17 @@ float___getformat__(PyTypeObject *type, PyObject *arg)
PyObject *return_value = NULL;
const char *typestr;
if (!PyArg_Parse(arg, "s:__getformat__", &typestr)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__getformat__", "str", arg);
goto exit;
}
Py_ssize_t typestr_length;
typestr = PyUnicode_AsUTF8AndSize(arg, &typestr_length);
if (typestr == NULL) {
goto exit;
}
if (strlen(typestr) != (size_t)typestr_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = float___getformat___impl(type, typestr);
@ -297,12 +307,17 @@ float___format__(PyObject *self, PyObject *arg)
PyObject *return_value = NULL;
PyObject *format_spec;
if (!PyArg_Parse(arg, "U:__format__", &format_spec)) {
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("__format__", "str", arg);
goto exit;
}
if (PyUnicode_READY(arg) == -1) {
goto exit;
}
format_spec = arg;
return_value = float___format___impl(self, format_spec);
exit:
return return_value;
}
/*[clinic end generated code: output=091dd499f5386a6c input=a9049054013a1b77]*/
/*[clinic end generated code: output=e8f8be828462d58b input=a9049054013a1b77]*/