Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update the doc
  • Loading branch information
methane authored Apr 3, 2022
commit 11c614c74d32e933185c899e0b6fdf26a69b8c41
11 changes: 8 additions & 3 deletions Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,13 @@ High-level Module Interface
This is a helper function for callables that use :func:`open` or
:class:`TextIOWrapper` and have an ``encoding=None`` parameter.

This function returns *encoding* if it is not ``None`` and ``"locale"`` if
*encoding* is ``None``.
This function returns *encoding* if it is not ``None``.
Otherwise, it returns ``"locale"`` or ``"utf-8"`` depending on
:ref:`UTF-8 Mode <utf8-mode>`.

This function emits an :class:`EncodingWarning` if
:data:`sys.flags.warn_default_encoding <sys.flags>` is true and *encoding*
is None. *stacklevel* specifies where the warning is emitted.
is ``None``. *stacklevel* specifies where the warning is emitted.
For example::

def read_text(path, encoding=None):
Expand All @@ -217,6 +218,10 @@ High-level Module Interface
See :ref:`io-text-encoding` for more information.

.. versionadded:: 3.10

.. versionchanged:: 3.11
:func:`text_encoding` returns "utf-8" when UTF-8 mode is enabled and
*encoding* is ``None``.


.. exception:: BlockingIOError
Expand Down