bpo-23867: Argument Clinic: inline parsing code for a single positional parameter. (GH-9689)
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 @@
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 @@
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]*/