diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-25 11:23:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-25 11:23:47 (GMT) |
commit | 32d96a2b5bc3136d45a66adbdb45fac351b520ce (patch) | |
tree | acf51c9945f764ab103597c9cba376f154aa600d /Objects/clinic/floatobject.c.h | |
parent | 65ce60aef150776f884715b4315a10a0d6ae769e (diff) | |
download | cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.zip cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.gz cpython-32d96a2b5bc3136d45a66adbdb45fac351b520ce.tar.bz2 |
bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
Diffstat (limited to 'Objects/clinic/floatobject.c.h')
-rw-r--r-- | Objects/clinic/floatobject.c.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h index 8ff2a2b..28b24d0 100644 --- a/Objects/clinic/floatobject.c.h +++ b/Objects/clinic/floatobject.c.h @@ -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]*/ |