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/bufferobject.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/bufferobject.c')
-rw-r--r-- | Objects/bufferobject.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c index 4c213ce..242261f 100644 --- a/Objects/bufferobject.c +++ b/Objects/bufferobject.c @@ -184,28 +184,22 @@ buffer_compare(PyBufferObject *self, PyBufferObject *other) static PyObject * buffer_repr(PyBufferObject *self) { - char buf[300]; char *status = self->b_readonly ? "read-only" : "read-write"; if ( self->b_base == NULL ) - { - sprintf(buf, "<%s buffer ptr %p, size %d at %p>", - status, - self->b_ptr, - self->b_size, - self); - } + return PyString_FromFormat("<%s buffer ptr %p, size %d at %p>", + status, + self->b_ptr, + self->b_size, + self); else - { - sprintf(buf, "<%s buffer for %p, ptr %p, size %d at %p>", + return PyString_FromFormat( + "<%s buffer for %p, ptr %p, size %d at %p>", status, self->b_base, self->b_ptr, self->b_size, self); - } - - return PyString_FromString(buf); } static long |