diff --git a/Modules/operator.c b/Modules/operator.c --- a/Modules/operator.c +++ b/Modules/operator.c @@ -214,7 +214,7 @@ "Return 'a == b'. This function uses an approach designed to prevent\n" "timing analysis, making it appropriate for cryptography.\n" "a and b must both be of the same type: either str (ASCII only),\n" -"or any type that supports the buffer protocol (e.g. bytes).\n" +"or any bytes-like object.\n" "\n" "Note: If a and b are of different lengths, or if an error occurs,\n" "a timing attack could theoretically reveal information about the\n" diff --git a/Objects/abstract.c b/Objects/abstract.c --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -237,8 +237,7 @@ 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; @@ -283,7 +282,7 @@ 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; } @@ -313,7 +312,7 @@ 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; } @@ -332,7 +331,7 @@ { 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; } @@ -507,8 +506,8 @@ 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; } diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -82,7 +82,7 @@ if (buffer == NULL || buffer->bf_getbuffer == NULL) { PyErr_Format(PyExc_TypeError, - "Type %.100s doesn't support the buffer API", + "a bytes-like object is required, not '%.100s'", Py_TYPE(obj)->tp_name); return -1; } diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -371,7 +371,7 @@ if (buffer == NULL || buffer->bf_getbuffer == NULL) { PyErr_Format(PyExc_TypeError, - "Type %.100s doesn't support the buffer API", + "a bytes-like object is required, not '%.100s'", Py_TYPE(obj)->tp_name); return -1; } diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -15,7 +15,7 @@ if (buffer == NULL || buffer->bf_getbuffer == NULL) { PyErr_Format(PyExc_TypeError, - "Type %.100s doesn't support the buffer API", + "a bytes-like object is required, not '%.100s'", Py_TYPE(obj)->tp_name); return -1; } diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4817,9 +4817,7 @@ \n\ Return the integer represented by the given array of bytes.\n\ \n\ -The bytes argument must either support the buffer protocol or be an\n\ -iterable object producing bytes. Bytes and bytearray are examples of\n\ -built-in objects that support the buffer protocol.\n\ +The bytes argument must be a bytes-like object (e.g. bytes or bytearray).\n\ \n\ The byteorder argument determines the byte order used to represent the\n\ integer. If byteorder is 'big', the most significant byte is at the\n\ diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -795,7 +795,7 @@ } PyErr_Format(PyExc_TypeError, - "memoryview: %.200s object does not have the buffer interface", + "memoryview: a bytes-like object is required, not '%.200s'", Py_TYPE(v)->tp_name); return NULL; } diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1225,7 +1225,8 @@ supports it directly. */ if (PyObject_GetBuffer(arg, (Py_buffer*)p, PyBUF_WRITABLE) < 0) { PyErr_Clear(); - return converterr("read-write buffer", arg, msgbuf, bufsize); + return converterr("read-write bytes-like object", + arg, msgbuf, bufsize); } if (!PyBuffer_IsContiguous((Py_buffer*)p, 'C')) { PyBuffer_Release((Py_buffer*)p); @@ -1263,7 +1264,7 @@ *errmsg = NULL; *p = NULL; if (pb != NULL && pb->bf_releasebuffer != NULL) { - *errmsg = "read-only pinned buffer"; + *errmsg = "read-only bytes-like object"; return -1; } @@ -1279,7 +1280,7 @@ getbuffer(PyObject *arg, Py_buffer *view, char **errmsg) { if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) { - *errmsg = "bytes or buffer"; + *errmsg = "bytes-like object"; return -1; } if (!PyBuffer_IsContiguous(view, 'C')) {

AltStyle によって変換されたページ (->オリジナル) /