mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Fixing the spelling of "writeable" to "writable", particularly PyBUF_WRITEABLE.
This commit is contained in:
parent
a5b8e04bd5
commit
54cf12b625
13 changed files with 33 additions and 31 deletions
|
@ -944,7 +944,7 @@ Buffer Protocol
|
||||||
|
|
||||||
.. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
|
.. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len)
|
||||||
|
|
||||||
Returns a pointer to a writeable memory location. The *obj* argument must
|
Returns a pointer to a writable memory location. The *obj* argument must
|
||||||
support the single-segment, character buffer interface. On success, returns
|
support the single-segment, character buffer interface. On success, returns
|
||||||
``0``, sets *buffer* to the memory location and *buffer_len* to the buffer
|
``0``, sets *buffer* to the memory location and *buffer_len* to the buffer
|
||||||
length. Returns ``-1`` and sets a :exc:`TypeError` on error.
|
length. Returns ``-1`` and sets a :exc:`TypeError` on error.
|
||||||
|
|
|
@ -1882,7 +1882,7 @@ could be used to pass around structured data in its native, in-memory format.
|
||||||
|
|
||||||
Return a new writable buffer object. Parameters and exceptions are similar to
|
Return a new writable buffer object. Parameters and exceptions are similar to
|
||||||
those for :cfunc:`PyBuffer_FromObject`. If the *base* object does not export
|
those for :cfunc:`PyBuffer_FromObject`. If the *base* object does not export
|
||||||
the writeable buffer protocol, then :exc:`TypeError` is raised.
|
the writable buffer protocol, then :exc:`TypeError` is raised.
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
|
.. cfunction:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)
|
||||||
|
|
|
@ -524,9 +524,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
|
||||||
Py_ssize_t *buffer_len);
|
Py_ssize_t *buffer_len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Takes an arbitrary object which must support the (writeable,
|
Takes an arbitrary object which must support the (writable,
|
||||||
single segment) buffer interface and returns a pointer to a
|
single segment) buffer interface and returns a pointer to a
|
||||||
writeable memory location in buffer of size buffer_len.
|
writable memory location in buffer of size buffer_len.
|
||||||
|
|
||||||
0 is returned on success. buffer and buffer_len are only
|
0 is returned on success. buffer and buffer_len are only
|
||||||
set in case no error occurrs. Otherwise, -1 is returned and
|
set in case no error occurrs. Otherwise, -1 is returned and
|
||||||
|
|
|
@ -33,15 +33,15 @@ PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, int buffertype
|
||||||
|
|
||||||
The buffertype argument can be PyBUF_READ, PyBUF_WRITE,
|
The buffertype argument can be PyBUF_READ, PyBUF_WRITE,
|
||||||
PyBUF_UPDATEIFCOPY to determine whether the returned buffer
|
PyBUF_UPDATEIFCOPY to determine whether the returned buffer
|
||||||
should be READONLY, WRITEABLE, or set to update the
|
should be READONLY, WRITABLE, or set to update the
|
||||||
original buffer if a copy must be made. If buffertype is
|
original buffer if a copy must be made. If buffertype is
|
||||||
PyBUF_WRITE and the buffer is not contiguous an error will
|
PyBUF_WRITE and the buffer is not contiguous an error will
|
||||||
be raised. In this circumstance, the user can use
|
be raised. In this circumstance, the user can use
|
||||||
PyBUF_UPDATEIFCOPY to ensure that a a writeable temporary
|
PyBUF_UPDATEIFCOPY to ensure that a a writable temporary
|
||||||
contiguous buffer is returned. The contents of this
|
contiguous buffer is returned. The contents of this
|
||||||
contiguous buffer will be copied back into the original
|
contiguous buffer will be copied back into the original
|
||||||
object after the memoryview object is deleted as long as
|
object after the memoryview object is deleted as long as
|
||||||
the original object is writeable and allows setting its
|
the original object is writable and allows setting its
|
||||||
memory to "readonly". If this is not allowed by the
|
memory to "readonly". If this is not allowed by the
|
||||||
original object, then a BufferError is raised.
|
original object, then a BufferError is raised.
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,9 @@ typedef void (*releasebufferproc)(PyObject *, PyBuffer *);
|
||||||
/* Flags for getting buffers */
|
/* Flags for getting buffers */
|
||||||
#define PyBUF_SIMPLE 0
|
#define PyBUF_SIMPLE 0
|
||||||
#define PyBUF_CHARACTER 1
|
#define PyBUF_CHARACTER 1
|
||||||
#define PyBUF_WRITEABLE 0x0002
|
#define PyBUF_WRITABLE 0x0002
|
||||||
|
/* we used to include an E, backwards compatible alias */
|
||||||
|
#define PyBUF_WRITEABLE PyBUF_WRITABLE
|
||||||
#define PyBUF_LOCKDATA 0x0004
|
#define PyBUF_LOCKDATA 0x0004
|
||||||
#define PyBUF_FORMAT 0x0008
|
#define PyBUF_FORMAT 0x0008
|
||||||
#define PyBUF_ND 0x0010
|
#define PyBUF_ND 0x0010
|
||||||
|
@ -172,19 +174,19 @@ typedef void (*releasebufferproc)(PyObject *, PyBuffer *);
|
||||||
#define PyBUF_ANY_CONTIGUOUS (0x0100 | PyBUF_STRIDES)
|
#define PyBUF_ANY_CONTIGUOUS (0x0100 | PyBUF_STRIDES)
|
||||||
#define PyBUF_INDIRECT (0x0200 | PyBUF_STRIDES)
|
#define PyBUF_INDIRECT (0x0200 | PyBUF_STRIDES)
|
||||||
|
|
||||||
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITEABLE)
|
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
|
||||||
#define PyBUF_CONTIG_RO (PyBUF_ND)
|
#define PyBUF_CONTIG_RO (PyBUF_ND)
|
||||||
#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCKDATA)
|
#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCKDATA)
|
||||||
|
|
||||||
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITEABLE)
|
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
|
||||||
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
|
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
|
||||||
#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA)
|
#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA)
|
||||||
|
|
||||||
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITEABLE | PyBUF_FORMAT)
|
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
|
||||||
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
|
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
|
||||||
#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA | PyBUF_FORMAT)
|
#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA | PyBUF_FORMAT)
|
||||||
|
|
||||||
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITEABLE | PyBUF_FORMAT)
|
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
|
||||||
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
|
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
|
||||||
#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCKDATA | PyBUF_FORMAT)
|
#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCKDATA | PyBUF_FORMAT)
|
||||||
|
|
||||||
|
|
|
@ -1346,7 +1346,7 @@ class _Prop_format(aetools.NProperty):
|
||||||
which = 'Frmt'
|
which = 'Frmt'
|
||||||
want = 'PthF'
|
want = 'PthF'
|
||||||
class _Prop_framework(aetools.NProperty):
|
class _Prop_framework(aetools.NProperty):
|
||||||
"""framework - Is the path a Mac OS X framework style path? (This flag is readable but not writeable from AppleScript.) """
|
"""framework - Is the path a Mac OS X framework style path? (This flag is readable but not writable from AppleScript.) """
|
||||||
which = 'Frmw'
|
which = 'Frmw'
|
||||||
want = 'bool'
|
want = 'bool'
|
||||||
class _Prop_host_flags(aetools.NProperty):
|
class _Prop_host_flags(aetools.NProperty):
|
||||||
|
|
|
@ -135,7 +135,7 @@ def _decode(pathname, verbose=0):
|
||||||
return newpathname
|
return newpathname
|
||||||
if hasattr(os, 'access') and not \
|
if hasattr(os, 'access') and not \
|
||||||
os.access(os.path.dirname(pathname), os.W_OK|os.X_OK):
|
os.access(os.path.dirname(pathname), os.W_OK|os.X_OK):
|
||||||
# The destination directory isn't writeable. Create the file in
|
# The destination directory isn't writable. Create the file in
|
||||||
# a temporary directory
|
# a temporary directory
|
||||||
import tempfile
|
import tempfile
|
||||||
fd, newpathname = tempfile.mkstemp(".rsrc")
|
fd, newpathname = tempfile.mkstemp(".rsrc")
|
||||||
|
|
|
@ -403,7 +403,7 @@ Extension modules
|
||||||
- os.urandom has been added for systems that support sources of random
|
- os.urandom has been added for systems that support sources of random
|
||||||
data.
|
data.
|
||||||
|
|
||||||
- Patch 1012740: truncate() on a writeable cStringIO now resets the
|
- Patch 1012740: truncate() on a writable cStringIO now resets the
|
||||||
position to the end of the stream. This is consistent with the original
|
position to the end of the stream. This is consistent with the original
|
||||||
StringIO module and avoids inadvertently resurrecting data that was
|
StringIO module and avoids inadvertently resurrecting data that was
|
||||||
supposed to have been truncated away.
|
supposed to have been truncated away.
|
||||||
|
|
|
@ -155,7 +155,7 @@ main(int argc, char **argv)
|
||||||
fprintf(stderr, "%s: %s has the wrong owner\n", argv[0],
|
fprintf(stderr, "%s: %s has the wrong owner\n", argv[0],
|
||||||
FULL_PATH);
|
FULL_PATH);
|
||||||
fprintf(stderr, "The script should be owned by root,\n");
|
fprintf(stderr, "The script should be owned by root,\n");
|
||||||
fprintf(stderr, "and shouldn't be writeable by anyone.\n");
|
fprintf(stderr, "and shouldn't be writable by anyone.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ mmap_find_method(mmap_object *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
is_writeable(mmap_object *self)
|
is_writable(mmap_object *self)
|
||||||
{
|
{
|
||||||
if (self->access != ACCESS_READ)
|
if (self->access != ACCESS_READ)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -307,7 +307,7 @@ mmap_write_method(mmap_object *self,
|
||||||
if (!PyArg_ParseTuple(args, "s#:write", &data, &length))
|
if (!PyArg_ParseTuple(args, "s#:write", &data, &length))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (!is_writeable(self))
|
if (!is_writable(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((self->pos + length) > self->size) {
|
if ((self->pos + length) > self->size) {
|
||||||
|
@ -330,7 +330,7 @@ mmap_write_byte_method(mmap_object *self,
|
||||||
if (!PyArg_ParseTuple(args, "c:write_byte", &value))
|
if (!PyArg_ParseTuple(args, "c:write_byte", &value))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (!is_writeable(self))
|
if (!is_writable(self))
|
||||||
return NULL;
|
return NULL;
|
||||||
*(self->data+self->pos) = value;
|
*(self->data+self->pos) = value;
|
||||||
self->pos += 1;
|
self->pos += 1;
|
||||||
|
@ -562,7 +562,7 @@ mmap_move_method(mmap_object *self, PyObject *args)
|
||||||
unsigned long dest, src, count;
|
unsigned long dest, src, count;
|
||||||
CHECK_VALID(NULL);
|
CHECK_VALID(NULL);
|
||||||
if (!PyArg_ParseTuple(args, "kkk:move", &dest, &src, &count) ||
|
if (!PyArg_ParseTuple(args, "kkk:move", &dest, &src, &count) ||
|
||||||
!is_writeable(self)) {
|
!is_writable(self)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
/* bounds check the values */
|
/* bounds check the values */
|
||||||
|
@ -733,7 +733,7 @@ mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
|
||||||
"mmap assignment must be length-1 bytes()");
|
"mmap assignment must be length-1 bytes()");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!is_writeable(self))
|
if (!is_writable(self))
|
||||||
return -1;
|
return -1;
|
||||||
buf = PyBytes_AsString(v);
|
buf = PyBytes_AsString(v);
|
||||||
self->data[i] = buf[0];
|
self->data[i] = buf[0];
|
||||||
|
@ -768,7 +768,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
|
||||||
"mmap assignment must be length-1 bytes()");
|
"mmap assignment must be length-1 bytes()");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!is_writeable(self))
|
if (!is_writable(self))
|
||||||
return -1;
|
return -1;
|
||||||
buf = PyBytes_AsString(value);
|
buf = PyBytes_AsString(value);
|
||||||
self->data[i] = buf[0];
|
self->data[i] = buf[0];
|
||||||
|
@ -797,7 +797,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
|
||||||
"mmap slice assignment is wrong size");
|
"mmap slice assignment is wrong size");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!is_writeable(self))
|
if (!is_writable(self))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (slicelen == 0)
|
if (slicelen == 0)
|
||||||
|
|
|
@ -1831,7 +1831,7 @@ internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen,
|
||||||
timeout = 1;
|
timeout = 1;
|
||||||
} else if (res > 0) {
|
} else if (res > 0) {
|
||||||
if (FD_ISSET(s->sock_fd, &fds))
|
if (FD_ISSET(s->sock_fd, &fds))
|
||||||
/* The socket is in the writeable set - this
|
/* The socket is in the writable set - this
|
||||||
means connected */
|
means connected */
|
||||||
res = 0;
|
res = 0;
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -304,9 +304,9 @@ int PyObject_AsWriteBuffer(PyObject *obj,
|
||||||
pb = obj->ob_type->tp_as_buffer;
|
pb = obj->ob_type->tp_as_buffer;
|
||||||
if (pb == NULL ||
|
if (pb == NULL ||
|
||||||
pb->bf_getbuffer == NULL ||
|
pb->bf_getbuffer == NULL ||
|
||||||
((*pb->bf_getbuffer)(obj, &view, PyBUF_WRITEABLE) != 0)) {
|
((*pb->bf_getbuffer)(obj, &view, PyBUF_WRITABLE) != 0)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"expected an object with a writeable buffer interface");
|
"expected an object with a writable buffer interface");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,10 +659,10 @@ PyBuffer_FillInfo(PyBuffer *view, void *buf, Py_ssize_t len,
|
||||||
"Cannot make this object read-only.");
|
"Cannot make this object read-only.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (((flags & PyBUF_WRITEABLE) == PyBUF_WRITEABLE) &&
|
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
|
||||||
readonly == 1) {
|
readonly == 1) {
|
||||||
PyErr_SetString(PyExc_BufferError,
|
PyErr_SetString(PyExc_BufferError,
|
||||||
"Object is not writeable.");
|
"Object is not writable.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,8 +183,8 @@ _indirect_copy_nd(char *dest, PyBuffer *view, char fort)
|
||||||
buffertype
|
buffertype
|
||||||
|
|
||||||
PyBUF_READ buffer only needs to be read-only
|
PyBUF_READ buffer only needs to be read-only
|
||||||
PyBUF_WRITE buffer needs to be writeable (give error if not contiguous)
|
PyBUF_WRITE buffer needs to be writable (give error if not contiguous)
|
||||||
PyBUF_SHADOW buffer needs to be writeable so shadow it with
|
PyBUF_SHADOW buffer needs to be writable so shadow it with
|
||||||
a contiguous buffer if it is not. The view will point to
|
a contiguous buffer if it is not. The view will point to
|
||||||
the shadow buffer which can be written to and then
|
the shadow buffer which can be written to and then
|
||||||
will be copied back into the other buffer when the memory
|
will be copied back into the other buffer when the memory
|
||||||
|
@ -235,7 +235,7 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort)
|
||||||
if (buffertype == PyBUF_WRITE) {
|
if (buffertype == PyBUF_WRITE) {
|
||||||
PyObject_DEL(mem);
|
PyObject_DEL(mem);
|
||||||
PyErr_SetString(PyExc_BufferError,
|
PyErr_SetString(PyExc_BufferError,
|
||||||
"writeable contiguous buffer requested for a non-contiguous" \
|
"writable contiguous buffer requested for a non-contiguous" \
|
||||||
"object.");
|
"object.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue