diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-06-11 16:36:59 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-06-11 16:36:59 (GMT) |
commit | d7fb7644da4a79cf153045536c1e81da5ee706a0 (patch) | |
tree | 5845faa89fa78d864344ea7cbe66bb93d2e51b3e /Objects/classobject.c | |
parent | 3ef72bb0a9b2e648537f0334a0d86fea0a21af04 (diff) | |
download | cpython-d7fb7644da4a79cf153045536c1e81da5ee706a0.zip cpython-d7fb7644da4a79cf153045536c1e81da5ee706a0.tar.gz cpython-d7fb7644da4a79cf153045536c1e81da5ee706a0.tar.bz2 |
Add a format specifier %V to PyUnicode_FromFormat(), that works similar to %U,
but requires an additional char * that will be used if the unicode object is
NULL.
Use %V in descrobject.c and classobject.c.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index 2dcc88f..9c9c49e 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -227,7 +227,7 @@ method_repr(PyMethodObject *a) PyObject *func = a->im_func; PyObject *klass = a->im_class; PyObject *funcname = NULL, *klassname = NULL, *result = NULL; - char *sfuncname = "?", *sklassname = "?"; + char *defname = "?"; funcname = PyObject_GetAttrString(func, "__name__"); if (funcname == NULL) { @@ -239,8 +239,6 @@ method_repr(PyMethodObject *a) Py_DECREF(funcname); funcname = NULL; } - else - sfuncname = PyUnicode_AsString(funcname); if (klass == NULL) klassname = NULL; else { @@ -254,16 +252,16 @@ method_repr(PyMethodObject *a) Py_DECREF(klassname); klassname = NULL; } - else - sklassname = PyUnicode_AsString(klassname); } if (self == NULL) - result = PyUnicode_FromFormat("<unbound method %s.%s>", - sklassname, sfuncname); + result = PyUnicode_FromFormat("<unbound method %V.%V>", + klassname, defname, + funcname, defname); else { /* XXX Shouldn't use repr()/%R here! */ - result = PyUnicode_FromFormat("<bound method %s.%s of %R>", - sklassname, sfuncname, self); + result = PyUnicode_FromFormat("<bound method %V.%V of %R>", + klassname, defname, + funcname, defname, self); } Py_XDECREF(funcname); Py_XDECREF(klassname); |