-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-99991: improve docs on str.encode and bytes.decode #100198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
317860f
86c44a4
06aaf7b
4330d08
dab7ee1
17e9503
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1625,13 +1625,15 @@ expression support in the :mod:`re` module). | |
.. method:: str.encode(encoding="utf-8", errors="strict") | ||
|
||
Return an encoded version of the string as a bytes object. Default encoding | ||
is ``'utf-8'``. *errors* may be given to set a different error handling scheme. | ||
The default for *errors* is ``'strict'``, meaning that encoding errors raise | ||
a :exc:`UnicodeError`. Other possible | ||
values are ``'ignore'``, ``'replace'``, ``'xmlcharrefreplace'``, | ||
``'backslashreplace'`` and any other name registered via | ||
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a | ||
list of possible encodings, see section :ref:`standard-encodings`. | ||
is ``'utf-8'``. And for a list of possible encodings, see section | ||
:ref:`standard-encodings`. | ||
bizzyvinci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
*errors* may be given to set a different error handling scheme. The | ||
default for *errors* is ``'strict'``, meaning that encoding errors raise | ||
a :exc:`UnicodeError`. Other possible values are ``'ignore'``, | ||
``'replace'``, ``'xmlcharrefreplace'``, ``'backslashreplace'`` and any | ||
other name registered via :func:`codecs.register_error`, see section | ||
:ref:`error-handlers`. | ||
bizzyvinci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
By default, the *errors* argument is not checked for best performances, but | ||
only used at the first encoding error. Enable the :ref:`Python Development | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was not able to actually make this as suggestion, but this implements the revision from the issue, while still including the key details from the previous version. For performance reasons, the value of *errors* is not checked for validity
unless an encoding error actually occurs,
:ref:`Python Development Mode <devmode>` is enabled
or a :ref:`debug build <debug-build>` is used. |
||
|
@@ -2760,12 +2762,14 @@ arbitrary binary data. | |
bytearray.decode(encoding="utf-8", errors="strict") | ||
|
||
Return a string decoded from the given bytes. Default encoding is | ||
bizzyvinci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``'utf-8'``. *errors* may be given to set a different | ||
error handling scheme. The default for *errors* is ``'strict'``, meaning | ||
that encoding errors raise a :exc:`UnicodeError`. Other possible values are | ||
``'ignore'``, ``'replace'`` and any other name registered via | ||
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a | ||
list of possible encodings, see section :ref:`standard-encodings`. | ||
``'utf-8'``. And for a list of possible encodings, see section | ||
:ref:`standard-encodings`. | ||
bizzyvinci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
*errors* may be given to set a different error handling scheme. The | ||
default for *errors* is ``'strict'``, meaning that encoding errors raise a | ||
:exc:`UnicodeError`. Other possible values are ``'ignore'``, ``'replace'`` | ||
and any other name registered via :func:`codecs.register_error`, see | ||
section :ref:`error-handlers`. | ||
bizzyvinci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
By default, the *errors* argument is not checked for best performances, but | ||
only used at the first decoding error. Enable the :ref:`Python Development | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was not able to actually make this as suggestion, but this implements the revision from the issue, while still including the key details from the previous version. For performance reasons, the value of *errors* is not checked for validity
unless a decoding error actually occurs,
:ref:`Python Development Mode <devmode>` is enabled
or a :ref:`debug build <debug-build>` is used. |
||
|
Uh oh!
There was an error while loading. Please reload this page.