mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
repr's converted to using PyString_FromFormat() instead of sprintf'ing
into a hardcoded char* buffer. Closes patch #454743.
This commit is contained in:
parent
dadace004b
commit
7ce3694a52
11 changed files with 95 additions and 136 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue