summaryrefslogtreecommitdiffstats
path: root/Objects/memoryobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/memoryobject.c')
-rw-r--r--Objects/memoryobject.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 0be8493..b611dc8 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -48,9 +48,6 @@
*/
-#define XSTRINGIZE(v) #v
-#define STRINGIZE(v) XSTRINGIZE(v)
-
#define CHECK_MBUF_RELEASED(mbuf) \
if (((_PyManagedBufferObject *)mbuf)->flags&_Py_MANAGED_BUFFER_RELEASED) { \
PyErr_SetString(PyExc_ValueError, \
@@ -223,7 +220,7 @@ PyTypeObject _PyManagedBuffer_Type = {
PyDoc_STRVAR(memory_doc,
-"memoryview(object)\n\
+"memoryview($module, object)\n--\n\
\n\
Create a new memoryview object which references the given object.");
@@ -660,7 +657,7 @@ mbuf_add_view(_PyManagedBufferObject *mbuf, const Py_buffer *src)
if (src->ndim > PyBUF_MAX_NDIM) {
PyErr_SetString(PyExc_ValueError,
"memoryview: number of dimensions must not exceed "
- STRINGIZE(PyBUF_MAX_NDIM));
+ Py_STRINGIFY(PyBUF_MAX_NDIM));
return NULL;
}
@@ -795,7 +792,7 @@ PyMemoryView_FromObject(PyObject *v)
}
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;
}
@@ -1389,7 +1386,7 @@ memory_cast(PyMemoryViewObject *self, PyObject *args, PyObject *kwds)
if (ndim > PyBUF_MAX_NDIM) {
PyErr_SetString(PyExc_ValueError,
"memoryview: number of dimensions must not exceed "
- STRINGIZE(PyBUF_MAX_NDIM));
+ Py_STRINGIFY(PyBUF_MAX_NDIM));
return NULL;
}
if (self->view.ndim != 1 && ndim != 1) {
@@ -2948,6 +2945,7 @@ PyDoc_STRVAR(memory_f_contiguous_doc,
PyDoc_STRVAR(memory_contiguous_doc,
"A bool indicating whether the memory is contiguous.");
+
static PyGetSetDef memory_getsetlist[] = {
{"obj", (getter)memory_obj_get, NULL, memory_obj_doc},
{"nbytes", (getter)memory_nbytes_get, NULL, memory_nbytes_doc},
@@ -2965,19 +2963,19 @@ static PyGetSetDef memory_getsetlist[] = {
};
PyDoc_STRVAR(memory_release_doc,
-"M.release() -> None\n\
+"release($self, /)\n--\n\
\n\
Release the underlying buffer exposed by the memoryview object.");
PyDoc_STRVAR(memory_tobytes_doc,
-"M.tobytes() -> bytes\n\
+"tobytes($self, /)\n--\n\
\n\
Return the data in the buffer as a byte string.");
PyDoc_STRVAR(memory_tolist_doc,
-"M.tolist() -> list\n\
+"tolist($self, /)\n--\n\
\n\
Return the data in the buffer as a list of elements.");
PyDoc_STRVAR(memory_cast_doc,
-"M.cast(format[, shape]) -> memoryview\n\
+"cast($self, /, format, *, shape)\n--\n\
\n\
Cast a memoryview to a new format or shape.");