diff options
| author | R David Murray <rdmurray@bitdance.com> | 2014-10-05 15:47:01 (GMT) |
|---|---|---|
| committer | R David Murray <rdmurray@bitdance.com> | 2014-10-05 15:47:01 (GMT) |
| commit | 861470c83607a4312d3c65bce3e18414b965e586 (patch) | |
| tree | 48088d67e50d8599b00498c17b5c8b7a35b482f8 /Objects/abstract.c | |
| parent | d577cea8ab0d929c40de93947dd68b9709607b35 (diff) | |
| download | cpython-861470c83607a4312d3c65bce3e18414b965e586.zip cpython-861470c83607a4312d3c65bce3e18414b965e586.tar.gz cpython-861470c83607a4312d3c65bce3e18414b965e586.tar.bz2 | |
#16518: Bring error messages in harmony with docs ("bytes-like object")
Some time ago we changed the docs to consistently use the term 'bytes-like
object' in all the contexts where bytes, bytearray, memoryview, etc are used.
This patch (by Ezio Melotti) completes that work by changing the error
messages that previously reported that certain types did "not support the
buffer interface" to instead say that a bytes-like object is required. (The
glossary entry for bytes-like object references the discussion of the buffer
protocol in the docs.)
Diffstat (limited to 'Objects/abstract.c')
| -rw-r--r-- | Objects/abstract.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 177c34a..323c985 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -260,8 +260,7 @@ PyObject_AsCharBuffer(PyObject *obj, pb = obj->ob_type->tp_as_buffer; if (pb == NULL || pb->bf_getbuffer == NULL) { PyErr_SetString(PyExc_TypeError, - "expected bytes, bytearray " - "or buffer compatible object"); + "expected a bytes-like object"); return -1; } if ((*pb->bf_getbuffer)(obj, &view, PyBUF_SIMPLE)) return -1; @@ -306,7 +305,7 @@ int PyObject_AsReadBuffer(PyObject *obj, if (pb == NULL || pb->bf_getbuffer == NULL) { PyErr_SetString(PyExc_TypeError, - "expected an object with a buffer interface"); + "expected a bytes-like object"); return -1; } @@ -336,7 +335,7 @@ int PyObject_AsWriteBuffer(PyObject *obj, pb->bf_getbuffer == NULL || ((*pb->bf_getbuffer)(obj, &view, PyBUF_WRITABLE) != 0)) { PyErr_SetString(PyExc_TypeError, - "expected an object with a writable buffer interface"); + "expected a writable bytes-like object"); return -1; } @@ -355,7 +354,7 @@ PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { if (!PyObject_CheckBuffer(obj)) { PyErr_Format(PyExc_TypeError, - "'%.100s' does not support the buffer interface", + "a bytes-like object is required, not '%.100s'", Py_TYPE(obj)->tp_name); return -1; } @@ -530,8 +529,8 @@ int PyObject_CopyData(PyObject *dest, PyObject *src) if (!PyObject_CheckBuffer(dest) || !PyObject_CheckBuffer(src)) { PyErr_SetString(PyExc_TypeError, - "both destination and source must have the "\ - "buffer interface"); + "both destination and source must be "\ + "bytes-like objects"); return -1; } |
