Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4cfc0b5

Browse files
committed
#16518: merge with 3.3.
2 parents 4e59af7 + c228e96 commit 4cfc0b5

8 files changed

Lines changed: 24 additions & 28 deletions

File tree

Doc/c-api/arg.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Unless otherwise stated, buffers are not NUL-terminated.
7070
as *converter*.
7171

7272
``s*`` (:class:`str`, :class:`bytes`, :class:`bytearray` or buffer compatible object) [Py_buffer]
73-
This format accepts Unicode objects as well as objects supporting the
74-
buffer protocol.
73+
This format accepts Unicode objects as well as :term:`bytes-like object`\ s.
7574
It fills a :c:type:`Py_buffer` structure provided by the caller.
7675
In this case the resulting C string may contain embedded NUL bytes.
7776
Unicode objects are converted to C strings using ``'utf-8'`` encoding.
@@ -101,14 +100,14 @@ Unless otherwise stated, buffers are not NUL-terminated.
101100
contain embedded NUL bytes; if it does, a :exc:`TypeError`
102101
exception is raised.
103102

104-
``y*`` (:class:`bytes`, :class:`bytearray` or buffer compatible object) [Py_buffer]
105-
This variant on ``s*`` doesn't accept Unicode objects, only objects
106-
supporting the buffer protocol. **This is the recommended way to accept
103+
``y*`` (:class:`bytes`, :class:`bytearray` or :term:`bytes-like object`) [Py_buffer]
104+
This variant on ``s*`` doesn't accept Unicode objects, only
105+
:term:`bytes-like object`\ s. **This is the recommended way to accept
107106
binary data.**
108107

109108
``y#`` (:class:`bytes`) [const char \*, int]
110-
This variant on ``s#`` doesn't accept Unicode objects, only bytes-like
111-
objects.
109+
This variant on ``s#`` doesn't accept Unicode objects, only :term:`bytes-like
110+
object`\ s.
112111

113112
``S`` (:class:`bytes`) [PyBytesObject \*]
114113
Requires that the Python object is a :class:`bytes` object, without

Doc/c-api/bytearray.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Direct API functions
4040
.. c:function:: PyObject* PyByteArray_FromObject(PyObject *o)
4141
4242
Return a new bytearray object from any object, *o*, that implements the
43-
buffer protocol.
43+
:ref:`buffer protocol <bufferobjects>`.
4444
4545
.. XXX expand about the buffer protocol, at least somewhere
4646

Doc/library/array.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ The module defines the following type:
7373
.. class:: array(typecode[, initializer])
7474

7575
A new array whose items are restricted by *typecode*, and initialized
76-
from the optional *initializer* value, which must be a list, object
77-
supporting the buffer interface, or iterable over elements of the
76+
from the optional *initializer* value, which must be a list, a
77+
:term:`bytes-like object`, or iterable over elements of the
7878
appropriate type.
7979

8080
If given a list or string, the initializer is passed to the new array's
@@ -91,7 +91,7 @@ Array objects support the ordinary sequence operations of indexing, slicing,
9191
concatenation, and multiplication. When using slice assignment, the assigned
9292
value must be an array object with the same type code; in all other cases,
9393
:exc:`TypeError` is raised. Array objects also implement the buffer interface,
94-
and may be used wherever buffer objects are supported.
94+
and may be used wherever :term:`bytes-like object`\ s are supported.
9595

9696
The following data items and methods are also supported:
9797

Doc/library/binascii.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ higher-level modules.
2121
.. note::
2222

2323
``a2b_*`` functions accept Unicode strings containing only ASCII characters.
24-
Other functions only accept bytes and bytes-compatible objects (such as
25-
bytearray objects and other objects implementing the buffer API).
24+
Other functions only accept :term:`bytes-like object`\ s (such as
25+
:class:`bytes`, :class:`bytearray` and other objects that support the buffer
26+
protocol).
2627

2728
.. versionchanged:: 3.3
2829
ASCII-only unicode strings are now accepted by the ``a2b_*`` functions.

Doc/library/hashlib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ digests. The modern term is secure hash.
3232

3333
There is one constructor method named for each type of :dfn:`hash`. All return
3434
a hash object with the same simple interface. For example: use :func:`sha1` to
35-
create a SHA1 hash object. You can now feed this object with objects conforming
36-
to the buffer interface (normally :class:`bytes` objects) using the
37-
:meth:`update` method. At any point you can ask it for the :dfn:`digest` of the
35+
create a SHA1 hash object. You can now feed this object with :term:`bytes-like
36+
object`\ s (normally :class:`bytes`) using the :meth:`update` method.
37+
At any point you can ask it for the :dfn:`digest` of the
3838
concatenation of the data fed to it so far using the :meth:`digest` or
3939
:meth:`hexdigest` methods.
4040

Doc/library/hmac.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ This module also provides the following helper function:
7474
timing analysis by avoiding content-based short circuiting behaviour,
7575
making it appropriate for cryptography. *a* and *b* must both be of the
7676
same type: either :class:`str` (ASCII only, as e.g. returned by
77-
:meth:`HMAC.hexdigest`), or any type that supports the buffer protocol
78-
(e.g. :class:`bytes`).
77+
:meth:`HMAC.hexdigest`), or a :term:`bytes-like object`.
7978

8079
.. note::
8180

Doc/library/multiprocessing.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,7 @@ Connection objects are usually created using :func:`Pipe` -- see also
800800

801801
.. method:: send_bytes(buffer[, offset[, size]])
802802

803-
Send byte data from an object supporting the buffer interface as a
804-
complete message.
803+
Send byte data from a :term:`bytes-like object` as a complete message.
805804

806805
If *offset* is given then data is read from that position in *buffer*. If
807806
*size* is given then that many bytes will be read from buffer. Very large
@@ -832,7 +831,7 @@ Connection objects are usually created using :func:`Pipe` -- see also
832831
:exc:`EOFError` if there is nothing left to receive and the other end was
833832
closed.
834833

835-
*buffer* must be an object satisfying the writable buffer interface. If
834+
*buffer* must be a writable :term:`bytes-like object`. If
836835
*offset* is given then the message will be written into the buffer from
837836
that position. Offset must be a non-negative integer less than the
838837
length of *buffer* (in bytes).

Doc/library/stdtypes.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,8 @@ class`. In addition, it provides one more method:
519519
>>> int.from_bytes([255, 0, 0], byteorder='big')
520520
16711680
521521

522-
The argument *bytes* must either support the buffer protocol or be an
523-
iterable producing bytes. :class:`bytes` and :class:`bytearray` are
524-
examples of built-in objects that support the buffer protocol.
522+
The argument *bytes* must either be a :term:`bytes-like object` or an
523+
iterable producing bytes.
525524

526525
The *byteorder* argument determines the byte order used to represent the
527526
integer. If *byteorder* is ``"big"``, the most significant byte is at the
@@ -1417,10 +1416,9 @@ multiple fragments.
14171416
single: bytes; str (built-in class)
14181417

14191418
If at least one of *encoding* or *errors* is given, *object* should be a
1420-
:class:`bytes` or :class:`bytearray` object, or more generally any object
1421-
that supports the :ref:`buffer protocol <bufferobjects>`. In this case, if
1422-
*object* is a :class:`bytes` (or :class:`bytearray`) object, then
1423-
``str(bytes, encoding, errors)`` is equivalent to
1419+
:term:`bytes-like object` (e.g. :class:`bytes` or :class:`bytearray`). In
1420+
this case, if *object* is a :class:`bytes` (or :class:`bytearray`) object,
1421+
then ``str(bytes, encoding, errors)`` is equivalent to
14241422
:meth:`bytes.decode(encoding, errors) <bytes.decode>`. Otherwise, the bytes
14251423
object underlying the buffer object is obtained before calling
14261424
:meth:`bytes.decode`. See :ref:`binaryseq` and

0 commit comments

Comments
 (0)