diff options
Diffstat (limited to 'Objects/stringlib')
-rw-r--r-- | Objects/stringlib/formatter.h | 18 | ||||
-rw-r--r-- | Objects/stringlib/stringdefs.h | 1 | ||||
-rw-r--r-- | Objects/stringlib/unicodedefs.h | 1 |
3 files changed, 5 insertions, 15 deletions
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h index 8e2b8ef..ee0971d 100644 --- a/Objects/stringlib/formatter.h +++ b/Objects/stringlib/formatter.h @@ -768,12 +768,8 @@ FORMAT_STRING(PyObject* value, PyObject* args) PyObject *result = NULL; InternalFormatSpec format; - if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) + if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", &format_spec)) goto done; - if (!STRINGLIB_CHECK(format_spec)) { - PyErr_SetString(PyExc_TypeError, STRINGLIB_TYPE_NAME " object required"); - goto done; - } /* check for the special case of zero length format spec, make it equivalent to str(value) */ @@ -843,12 +839,8 @@ FORMAT_LONG(PyObject* value, PyObject* args) PyObject *tmp = NULL; InternalFormatSpec format; - if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) - goto done; - if (!STRINGLIB_CHECK(format_spec)) { - PyErr_SetString(PyExc_TypeError, STRINGLIB_TYPE_NAME " object required"); + if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", &format_spec)) goto done; - } /* check for the special case of zero length format spec, make it equivalent to str(value) */ @@ -917,12 +909,8 @@ FORMAT_FLOAT(PyObject *value, PyObject *args) PyObject *tmp = NULL; InternalFormatSpec format; - if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) - goto done; - if (!STRINGLIB_CHECK(format_spec)) { - PyErr_SetString(PyExc_TypeError, STRINGLIB_TYPE_NAME " object required"); + if (!PyArg_ParseTuple(args, STRINGLIB_PARSE_CODE ":__format__", &format_spec)) goto done; - } /* check for the special case of zero length format spec, make it equivalent to str(value) */ diff --git a/Objects/stringlib/stringdefs.h b/Objects/stringlib/stringdefs.h index af9bbd6..a4be17f 100644 --- a/Objects/stringlib/stringdefs.h +++ b/Objects/stringlib/stringdefs.h @@ -8,6 +8,7 @@ #define STRINGLIB_CHAR char #define STRINGLIB_TYPE_NAME "string" +#define STRINGLIB_PARSE_CODE "S" #define STRINGLIB_EMPTY string_empty #define STRINGLIB_ISDECIMAL(x) ((x >= '0') && (x <= '9')) #define STRINGLIB_TODECIMAL(x) (STRINGLIB_ISDECIMAL(x) ? (x - '0') : -1) diff --git a/Objects/stringlib/unicodedefs.h b/Objects/stringlib/unicodedefs.h index a50a3f2..25c1d4f 100644 --- a/Objects/stringlib/unicodedefs.h +++ b/Objects/stringlib/unicodedefs.h @@ -8,6 +8,7 @@ #define STRINGLIB_CHAR Py_UNICODE #define STRINGLIB_TYPE_NAME "unicode" +#define STRINGLIB_PARSE_CODE "U" #define STRINGLIB_EMPTY unicode_empty #define STRINGLIB_ISDECIMAL Py_UNICODE_ISDECIMAL #define STRINGLIB_TODECIMAL Py_UNICODE_TODECIMAL |