diff options
author | Barry Warsaw <barry@python.org> | 2001-08-24 18:34:26 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-08-24 18:34:26 (GMT) |
commit | 7ce3694a527afe425a2b9df65c049b0ef4e75960 (patch) | |
tree | 089937f432c69e85afbfc8308d5ebc86dd2c2c49 /Objects/descrobject.c | |
parent | dadace004b4b94dcc4437bafc9c8407fbb1bed74 (diff) | |
download | cpython-7ce3694a527afe425a2b9df65c049b0ef4e75960.zip cpython-7ce3694a527afe425a2b9df65c049b0ef4e75960.tar.gz cpython-7ce3694a527afe425a2b9df65c049b0ef4e75960.tar.bz2 |
repr's converted to using PyString_FromFormat() instead of sprintf'ing
into a hardcoded char* buffer.
Closes patch #454743.
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r-- | Objects/descrobject.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index efed1c0..44b20e2 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -55,38 +55,36 @@ descr_name(PyDescrObject *descr) static PyObject * descr_repr(PyDescrObject *descr, char *format) { - char buffer[500]; - - sprintf(buffer, format, descr_name(descr), descr->d_type->tp_name); - return PyString_FromString(buffer); + return PyString_FromFormat(format, descr_name(descr), + descr->d_type->tp_name); } static PyObject * method_repr(PyMethodDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - "<method '%.300s' of '%.100s' objects>"); + "<method '%s' of '%s' objects>"); } static PyObject * member_repr(PyMemberDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - "<member '%.300s' of '%.100s' objects>"); + "<member '%s' of '%s' objects>"); } static PyObject * getset_repr(PyGetSetDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - "<attribute '%.300s' of '%.100s' objects>"); + "<attribute '%s' of '%s' objects>"); } static PyObject * wrapper_repr(PyWrapperDescrObject *descr) { return descr_repr((PyDescrObject *)descr, - "<slot wrapper '%.300s' of '%.100s' objects>"); + "<slot wrapper '%s' of '%s' objects>"); } static int @@ -100,8 +98,8 @@ descr_check(PyDescrObject *descr, PyObject *obj, PyTypeObject *type, } if (!PyObject_IsInstance(obj, (PyObject *)(descr->d_type))) { PyErr_Format(PyExc_TypeError, - "descriptor '%.200s' for '%.100s' objects " - "doesn't apply to '%.100s' object", + "descriptor '%s' for '%s' objects " + "doesn't apply to '%s' object", descr_name((PyDescrObject *)descr), descr->d_type->tp_name, obj->ob_type->tp_name); |