Skip to content

Commit 317860f

Browse files
committed
improve str.encode and byte.decode
1 parent 748c6c0 commit 317860f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

Doc/library/stdtypes.rst

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,13 +1625,15 @@ expression support in the :mod:`re` module).
16251625
.. method:: str.encode(encoding="utf-8", errors="strict")
16261626

16271627
Return an encoded version of the string as a bytes object. Default encoding
1628-
is ``'utf-8'``. *errors* may be given to set a different error handling scheme.
1629-
The default for *errors* is ``'strict'``, meaning that encoding errors raise
1630-
a :exc:`UnicodeError`. Other possible
1631-
values are ``'ignore'``, ``'replace'``, ``'xmlcharrefreplace'``,
1632-
``'backslashreplace'`` and any other name registered via
1633-
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a
1634-
list of possible encodings, see section :ref:`standard-encodings`.
1628+
is ``'utf-8'``. And for a list of possible encodings, see section
1629+
:ref:`standard-encodings`.
1630+
1631+
*errors* may be given to set a different error handling scheme. The
1632+
default for *errors* is ``'strict'``, meaning that encoding errors raise
1633+
a :exc:`UnicodeError`. Other possible values are ``'ignore'``,
1634+
``'replace'``, ``'xmlcharrefreplace'``, ``'backslashreplace'`` and any
1635+
other name registered via :func:`codecs.register_error`, see section
1636+
:ref:`error-handlers`.
16351637

16361638
By default, the *errors* argument is not checked for best performances, but
16371639
only used at the first encoding error. Enable the :ref:`Python Development
@@ -2760,12 +2762,14 @@ arbitrary binary data.
27602762
bytearray.decode(encoding="utf-8", errors="strict")
27612763

27622764
Return a string decoded from the given bytes. Default encoding is
2763-
``'utf-8'``. *errors* may be given to set a different
2764-
error handling scheme. The default for *errors* is ``'strict'``, meaning
2765-
that encoding errors raise a :exc:`UnicodeError`. Other possible values are
2766-
``'ignore'``, ``'replace'`` and any other name registered via
2767-
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a
2768-
list of possible encodings, see section :ref:`standard-encodings`.
2765+
``'utf-8'``. And for a list of possible encodings, see section
2766+
:ref:`standard-encodings`.
2767+
2768+
*errors* may be given to set a different error handling scheme. The
2769+
default for *errors* is ``'strict'``, meaning that encoding errors raise a
2770+
:exc:`UnicodeError`. Other possible values are ``'ignore'``, ``'replace'``
2771+
and any other name registered via :func:`codecs.register_error`, see
2772+
section :ref:`error-handlers`.
27692773

27702774
By default, the *errors* argument is not checked for best performances, but
27712775
only used at the first decoding error. Enable the :ref:`Python Development

0 commit comments

Comments
 (0)