diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-06-05 00:56:46 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-06-05 00:56:46 (GMT) |
commit | 039c585805f50411f868dd315f1315ca7ccc9573 (patch) | |
tree | ad06ab215729ae7750debd81c7d62be24b5550c5 /Objects | |
parent | 3a2acb5040efba7afa45d3680d0eeca45a263305 (diff) | |
download | cpython-039c585805f50411f868dd315f1315ca7ccc9573.zip cpython-039c585805f50411f868dd315f1315ca7ccc9573.tar.gz cpython-039c585805f50411f868dd315f1315ca7ccc9573.tar.bz2 |
implement object.__format__ with PyObject_Format
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c4b9dbf..b9498e5 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3413,7 +3413,6 @@ object_format(PyObject *self, PyObject *args) PyObject *format_spec; PyObject *self_as_str = NULL; PyObject *result = NULL; - PyObject *format_meth = NULL; Py_ssize_t format_len; if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) @@ -3449,21 +3448,11 @@ object_format(PyObject *self, PyObject *args) goto done; */ } - - /* find the format function */ - format_meth = PyObject_GetAttrString(self_as_str, - "__format__"); - if (format_meth != NULL) { - /* and call it */ - result = PyObject_CallFunctionObjArgs(format_meth, - format_spec, - NULL); - } + return PyObject_Format(self_as_str, format_spec); } done: Py_XDECREF(self_as_str); - Py_XDECREF(format_meth); return result; } |