Mercurial > cpython-lru_cache-weakref
diff Objects/bufferobject.c @ 47527:52294af4b663 legacy-trunk
This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 09 Jun 2008 04:58:54 +0000 |
| parents | 4fe192d48960 |
| children | 1c964ed35ef9 |
line wrap: on
line diff
--- a/Objects/bufferobject.c Mon Jun 09 01:28:30 2008 +0000 +++ b/Objects/bufferobject.c Mon Jun 09 04:58:54 2008 +0000 @@ -287,13 +287,13 @@ const char *status = self->b_readonly ? "read-only" : "read-write"; if ( self->b_base == NULL ) - return PyBytes_FromFormat("<%s buffer ptr %p, size %zd at %p>", + return PyString_FromFormat("<%s buffer ptr %p, size %zd at %p>", status, self->b_ptr, self->b_size, self); else - return PyBytes_FromFormat( + return PyString_FromFormat( "<%s buffer for %p, size %zd, offset %zd at %p>", status, self->b_base, @@ -318,7 +318,7 @@ * underlying memory is immutable. b_readonly is a necessary but not * sufficient condition for a buffer to be hashable. Perhaps it would * be better to only allow hashing if the underlying object is known to - * be immutable (e.g. PyBytes_Check() is true). Another idea would + * be immutable (e.g. PyString_Check() is true). Another idea would * be to call tp_hash on the underlying object and see if it raises * an error. */ if ( !self->b_readonly ) @@ -349,7 +349,7 @@ Py_ssize_t size; if (!get_buf(self, &ptr, &size, ANY_BUFFER)) return NULL; - return PyBytes_FromStringAndSize((const char *)ptr, size); + return PyString_FromStringAndSize((const char *)ptr, size); } /* Sequence methods */ @@ -401,10 +401,10 @@ if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) return NULL; - ob = PyBytes_FromStringAndSize(NULL, size + count); + ob = PyString_FromStringAndSize(NULL, size + count); if ( ob == NULL ) return NULL; - p = PyBytes_AS_STRING(ob); + p = PyString_AS_STRING(ob); memcpy(p, ptr1, size); memcpy(p + size, ptr2, count); @@ -426,11 +426,11 @@ count = 0; if (!get_buf(self, &ptr, &size, ANY_BUFFER)) return NULL; - ob = PyBytes_FromStringAndSize(NULL, size * count); + ob = PyString_FromStringAndSize(NULL, size * count); if ( ob == NULL ) return NULL; - p = PyBytes_AS_STRING(ob); + p = PyString_AS_STRING(ob); while ( count-- ) { memcpy(p, ptr, size); @@ -454,7 +454,7 @@ PyErr_SetString(PyExc_IndexError, "buffer index out of range"); return NULL; } - return PyBytes_FromStringAndSize((char *)ptr + idx, 1); + return PyString_FromStringAndSize((char *)ptr + idx, 1); } static PyObject * @@ -472,7 +472,7 @@ right = size; if ( right < left ) right = left; - return PyBytes_FromStringAndSize((char *)ptr + left, + return PyString_FromStringAndSize((char *)ptr + left, right - left); } @@ -501,9 +501,9 @@ } if (slicelength <= 0) - return PyBytes_FromStringAndSize("", 0); + return PyString_FromStringAndSize("", 0); else if (step == 1) - return PyBytes_FromStringAndSize((char *)p + start, + return PyString_FromStringAndSize((char *)p + start, stop - start); else { PyObject *result; @@ -518,7 +518,7 @@ result_buf[i] = source_buf[cur]; } - result = PyBytes_FromStringAndSize(result_buf, + result = PyString_FromStringAndSize(result_buf, slicelength); PyMem_Free(result_buf); return result;
