mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
This commit is contained in:
parent
65ce60aef1
commit
32d96a2b5b
49 changed files with 1677 additions and 275 deletions
21
Objects/clinic/floatobject.c.h
generated
21
Objects/clinic/floatobject.c.h
generated
|
|
@ -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]*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue