From 7569dfe11d51a11bfb11002d31245b889916fb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20D=C3=B6rwald?= Date: Sat, 19 May 2007 21:49:49 +0000 Subject: Add a format specifier %R to PyUnicode_FromFormat(), which embeds the result of a call to PyObject_Repr() into the string. This makes it possible to simplify many repr implementations. PyUnicode_FromFormat() uses two steps to create the final string: A first pass through the format string determines the size of the final string and a second pass creates the string. To avoid calling PyObject_Repr() twice for each %R specifier, PyObject_Repr() is called during the size calculation step and the results are stored in an array (whose size is determined at the start by counting %R specifiers). --- Objects/classobject.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Objects/classobject.c') diff --git a/Objects/classobject.c b/Objects/classobject.c index e4687a3695..b7711d56d7 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -261,11 +261,9 @@ method_repr(PyMethodObject *a) result = PyUnicode_FromFormat("", sklassname, sfuncname); else { - result = PyUnicode_FromFormat("")); + /* XXX Shouldn't use repr()/%R here! */ + result = PyUnicode_FromFormat("", + sklassname, sfuncname, self); } Py_XDECREF(funcname); Py_XDECREF(klassname); -- cgit v1.2.1