summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-06-05 01:03:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-06-05 01:03:24 (GMT)
commitc03d7571c482668fc574be52a3edef7b0852738b (patch)
tree41eb53bd815887f2e9ae8df7a9c02ec7986f759e
parentda2cf04c2807e3b2f80e06306242238ddddaa260 (diff)
downloadcpython-c03d7571c482668fc574be52a3edef7b0852738b.zip
cpython-c03d7571c482668fc574be52a3edef7b0852738b.tar.gz
cpython-c03d7571c482668fc574be52a3edef7b0852738b.tar.bz2
Merged revisions 81709-81710 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81709 | benjamin.peterson | 2010-06-04 19:56:46 -0500 (Fri, 04 Jun 2010) | 1 line implement object.__format__ with PyObject_Format ........ r81710 | benjamin.peterson | 2010-06-04 20:00:10 -0500 (Fri, 04 Jun 2010) | 1 line fix ref counting ........
-rw-r--r--Objects/typeobject.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index adfb0ec..2d9d031 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3310,23 +3310,15 @@ object_format(PyObject *self, PyObject *args)
PyObject *format_spec;
PyObject *self_as_str = NULL;
PyObject *result = NULL;
- PyObject *format_meth = NULL;
if (!PyArg_ParseTuple(args, "U:__format__", &format_spec))
return NULL;
self_as_str = PyObject_Str(self);
- if (self_as_str != NULL) {
- /* 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);
- }
- }
+ if (self_as_str != NULL)
+ result = PyObject_Format(self_as_str, format_spec);
Py_XDECREF(self_as_str);
- Py_XDECREF(format_meth);
return result;
}