diff options
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/codecs.rst | 14 | ||||
-rw-r--r-- | Doc/library/functions.rst | 5 | ||||
-rw-r--r-- | Doc/library/io.rst | 11 |
3 files changed, 17 insertions, 13 deletions
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 3510f69..048f0e9 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -314,8 +314,8 @@ The following error handlers are only applicable to | | reference (only for encoding). Implemented | | | in :func:`xmlcharrefreplace_errors`. | +-------------------------+-----------------------------------------------+ -| ``'backslashreplace'`` | Replace with backslashed escape sequences | -| | (only for encoding). Implemented in | +| ``'backslashreplace'`` | Replace with backslashed escape sequences. | +| | Implemented in | | | :func:`backslashreplace_errors`. | +-------------------------+-----------------------------------------------+ | ``'namereplace'`` | Replace with ``\N{...}`` escape sequences | @@ -350,6 +350,10 @@ In addition, the following error handler is specific to the given codecs: .. versionadded:: 3.5 The ``'namereplace'`` error handler. +.. versionchanged:: 3.5 + The ``'backslashreplace'`` error handlers now works with decoding and + translating. + The set of allowed values can be extended by registering a new named error handler: @@ -417,9 +421,9 @@ functions: .. function:: backslashreplace_errors(exception) - Implements the ``'backslashreplace'`` error handling (for encoding with - :term:`text encodings <text encoding>` only): the - unencodable character is replaced by a backslashed escape sequence. + Implements the ``'backslashreplace'`` error handling (for + :term:`text encodings <text encoding>` only): malformed data is + replaced by a backslashed escape sequence. .. function:: namereplace_errors(exception) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index c6b66b5..eb28513 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -973,9 +973,8 @@ are always available. They are listed here in alphabetical order. Characters not supported by the encoding are replaced with the appropriate XML character reference ``&#nnn;``. - * ``'backslashreplace'`` (also only supported when writing) - replaces unsupported characters with Python's backslashed escape - sequences. + * ``'backslashreplace'`` replaces malformed data by Python's backslashed + escape sequences. * ``'namereplace'`` (also only supported when writing) replaces unsupported characters with ``\N{...}`` escape sequences. diff --git a/Doc/library/io.rst b/Doc/library/io.rst index c77db90..b0b1af3 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -825,11 +825,12 @@ Text I/O exception if there is an encoding error (the default of ``None`` has the same effect), or pass ``'ignore'`` to ignore errors. (Note that ignoring encoding errors can lead to data loss.) ``'replace'`` causes a replacement marker - (such as ``'?'``) to be inserted where there is malformed data. When - writing, ``'xmlcharrefreplace'`` (replace with the appropriate XML character - reference), ``'backslashreplace'`` (replace with backslashed escape - sequences) or ``'namereplace'`` (replace with ``\N{...}`` escape sequences) - can be used. Any other error handling name that has been registered with + (such as ``'?'``) to be inserted where there is malformed data. + ``'backslashreplace'`` causes malformed data to be replaced by a + backslashed escape sequence. When writing, ``'xmlcharrefreplace'`` + (replace with the appropriate XML character reference) or ``'namereplace'`` + (replace with ``\N{...}`` escape sequences) can be used. Any other error + handling name that has been registered with :func:`codecs.register_error` is also valid. .. index:: |