summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-05 20:26:10 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-05 20:26:10 (GMT)
commit92bf919ed0da8d7f112f9659e6065976e382bae1 (patch)
tree1876e54c89f619563d8b4218bb7fa5f05eb86b0a /Doc
parent1a7b8d143965c281467379123187e0ef323380c3 (diff)
parentb757c83ec626442a8804b9417790443bf13b4fc8 (diff)
downloadcpython-92bf919ed0da8d7f112f9659e6065976e382bae1.zip
cpython-92bf919ed0da8d7f112f9659e6065976e382bae1.tar.gz
cpython-92bf919ed0da8d7f112f9659e6065976e382bae1.tar.bz2
Issue #22581: Use more "bytes-like object" throughout the docs and comments.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/arg.rst27
-rw-r--r--Doc/c-api/unicode.rst3
-rw-r--r--Doc/library/socket.rst5
-rw-r--r--Doc/library/ssl.rst2
4 files changed, 20 insertions, 17 deletions
diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst
index 5d069b6..3c0f4b9 100644
--- a/Doc/c-api/arg.rst
+++ b/Doc/c-api/arg.rst
@@ -65,19 +65,20 @@ Unless otherwise stated, buffers are not NUL-terminated.
:exc:`UnicodeError` is raised.
.. note::
- This format does not accept bytes-like objects. If you want to accept
+ This format does not accept :term:`bytes-like objects
+ <bytes-like object>`. If you want to accept
filesystem paths and convert them to C character strings, it is
preferable to use the ``O&`` format with :c:func:`PyUnicode_FSConverter`
as *converter*.
-``s*`` (:class:`str`, :class:`bytes`, :class:`bytearray` or buffer compatible object) [Py_buffer]
- This format accepts Unicode objects as well as :term:`bytes-like object`\ s.
+``s*`` (:class:`str` or :term:`bytes-like object`) [Py_buffer]
+ This format accepts Unicode objects as well as bytes-like objects.
It fills a :c:type:`Py_buffer` structure provided by the caller.
In this case the resulting C string may contain embedded NUL bytes.
Unicode objects are converted to C strings using ``'utf-8'`` encoding.
-``s#`` (:class:`str`, :class:`bytes` or read-only buffer compatible object) [const char \*, int or :c:type:`Py_ssize_t`]
- Like ``s*``, except that it doesn't accept mutable buffer-like objects
+``s#`` (:class:`str`, read-only :term:`bytes-like object`) [const char \*, int or :c:type:`Py_ssize_t`]
+ Like ``s*``, except that it doesn't accept mutable bytes-like objects
such as :class:`bytearray`. The result is stored into two C variables,
the first one a pointer to a C string, the second one its length.
The string may contain embedded null bytes. Unicode objects are converted
@@ -87,28 +88,28 @@ Unless otherwise stated, buffers are not NUL-terminated.
Like ``s``, but the Python object may also be ``None``, in which case the C
pointer is set to *NULL*.
-``z*`` (:class:`str`, :class:`bytes`, :class:`bytearray`, buffer compatible object or ``None``) [Py_buffer]
+``z*`` (:class:`str`, :term:`bytes-like object` or ``None``) [Py_buffer]
Like ``s*``, but the Python object may also be ``None``, in which case the
``buf`` member of the :c:type:`Py_buffer` structure is set to *NULL*.
-``z#`` (:class:`str`, :class:`bytes`, read-only buffer compatible object or ``None``) [const char \*, int]
+``z#`` (:class:`str`, read-only :term:`bytes-like object` or ``None``) [const char \*, int]
Like ``s#``, but the Python object may also be ``None``, in which case the C
pointer is set to *NULL*.
-``y`` (:class:`bytes`) [const char \*]
+``y`` (read-only :term:`bytes-like object`) [const char \*]
This format converts a bytes-like object to a C pointer to a character
string; it does not accept Unicode objects. The bytes buffer must not
contain embedded NUL bytes; if it does, a :exc:`TypeError`
exception is raised.
-``y*`` (:class:`bytes`, :class:`bytearray` or :term:`bytes-like object`) [Py_buffer]
+``y*`` (:term:`bytes-like object`) [Py_buffer]
This variant on ``s*`` doesn't accept Unicode objects, only
- :term:`bytes-like object`\ s. **This is the recommended way to accept
+ bytes-like objects. **This is the recommended way to accept
binary data.**
-``y#`` (:class:`bytes`) [const char \*, int]
- This variant on ``s#`` doesn't accept Unicode objects, only :term:`bytes-like
- object`\ s.
+``y#`` (read-only :term:`bytes-like object`) [const char \*, int]
+ This variant on ``s#`` doesn't accept Unicode objects, only bytes-like
+ objects.
``S`` (:class:`bytes`) [PyBytesObject \*]
Requires that the Python object is a :class:`bytes` object, without
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index d86f99a..ed74f45 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -556,7 +556,8 @@ APIs:
Coerce an encoded object *obj* to an Unicode object and return a reference with
incremented refcount.
- :class:`bytes`, :class:`bytearray` and other char buffer compatible objects
+ :class:`bytes`, :class:`bytearray` and other
+ :term:`bytes-like objects <bytes-like object>`
are decoded according to the given *encoding* and using the error handling
defined by *errors*. Both can be *NULL* to have the interface use the default
values (see the next section for details).
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 830e82d..e330f0a 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -1123,7 +1123,8 @@ to sockets.
Send normal and ancillary data to the socket, gathering the
non-ancillary data from a series of buffers and concatenating it
into a single message. The *buffers* argument specifies the
- non-ancillary data as an iterable of buffer-compatible objects
+ non-ancillary data as an iterable of
+ :term:`bytes-like objects <bytes-like object>`
(e.g. :class:`bytes` objects); the operating system may set a limit
(:func:`~os.sysconf` value ``SC_IOV_MAX``) on the number of buffers
that can be used. The *ancdata* argument specifies the ancillary
@@ -1131,7 +1132,7 @@ to sockets.
``(cmsg_level, cmsg_type, cmsg_data)``, where *cmsg_level* and
*cmsg_type* are integers specifying the protocol level and
protocol-specific type respectively, and *cmsg_data* is a
- buffer-compatible object holding the associated data. Note that
+ bytes-like object holding the associated data. Note that
some systems (in particular, systems without :func:`CMSG_SPACE`)
might support sending only one control message per call. The
*flags* argument defaults to 0 and has the same meaning as for
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index f82e565..c4197a5 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -1104,7 +1104,7 @@ to speed up repeated connections from the same clients.
<http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html>`_.
The *cadata* object, if present, is either an ASCII string of one or more
- PEM-encoded certificates or a bytes-like object of DER-encoded
+ PEM-encoded certificates or a :term:`bytes-like object` of DER-encoded
certificates. Like with *capath* extra lines around PEM-encoded
certificates are ignored but at least one certificate must be present.