summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-06-25 22:51:05 (GMT)
committerGitHub <noreply@github.com>2019-06-25 22:51:05 (GMT)
commit22eb689cf3de7972a2789db3ad01a86949508ab7 (patch)
treea1d63fa4cf235008e73f92a18ebef57be54ce4a5 /Doc/library
parente1a63c4f21011a3ae77dff624196561070c83446 (diff)
downloadcpython-22eb689cf3de7972a2789db3ad01a86949508ab7.zip
cpython-22eb689cf3de7972a2789db3ad01a86949508ab7.tar.gz
cpython-22eb689cf3de7972a2789db3ad01a86949508ab7.tar.bz2
bpo-37388: Development mode check encoding and errors (GH-14341)
In development mode and in debug build, encoding and errors arguments are now checked on string encoding and decoding operations. Examples: open(), str.encode() and bytes.decode(). By default, for best performances, the errors argument is only checked at the first encoding/decoding error, and the encoding argument is sometimes ignored for empty strings.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/stdtypes.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 35a17a1..8575f8a 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1559,9 +1559,16 @@ expression support in the :mod:`re` module).
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a
list of possible encodings, see section :ref:`standard-encodings`.
+ By default, the *errors* argument is not checked for best performances, but
+ only used at the first encoding error. Enable the development mode
+ (:option:`-X` ``dev`` option), or use a debug build, to check *errors*.
+
.. versionchanged:: 3.1
Support for keyword arguments added.
+ .. versionchanged:: 3.9
+ The *errors* is now checked in development mode and in debug mode.
+
.. method:: str.endswith(suffix[, start[, end]])
@@ -2575,6 +2582,10 @@ arbitrary binary data.
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a
list of possible encodings, see section :ref:`standard-encodings`.
+ By default, the *errors* argument is not checked for best performances, but
+ only used at the first decoding error. Enable the development mode
+ (:option:`-X` ``dev`` option), or use a debug build, to check *errors*.
+
.. note::
Passing the *encoding* argument to :class:`str` allows decoding any
@@ -2584,6 +2595,9 @@ arbitrary binary data.
.. versionchanged:: 3.1
Added support for keyword arguments.
+ .. versionchanged:: 3.9
+ The *errors* is now checked in development mode and in debug mode.
+
.. method:: bytes.endswith(suffix[, start[, end]])
bytearray.endswith(suffix[, start[, end]])