bpo-42236: os.device_encoding() respects UTF-8 Mode (GH-23119)
On Unix, the os.device_encoding() function now returns 'UTF-8' rather
than the device encoding if the Python UTF-8 Mode is enabled.
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index f9f35b3..3ffcfa0 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -113,6 +113,8 @@
:ref:`error handler <error-handlers>` being enabled for :data:`sys.stdin`
and :data:`sys.stdout` (:data:`sys.stderr` continues to use
``backslashreplace`` as it does in the default locale-aware mode)
+* On Unix, :func:`os.device_encoding` returns ``'UTF-8'``. rather than the
+ device encoding.
Note that the standard stream settings in UTF-8 mode can be overridden by
:envvar:`PYTHONIOENCODING` (just as they can be in the default locale-aware
@@ -808,6 +810,12 @@
Return a string describing the encoding of the device associated with *fd*
if it is connected to a terminal; else return :const:`None`.
+ On Unix, if the :ref:`Python UTF-8 Mode <utf8-mode>` is enabled, return
+ ``'UTF-8'`` rather than the device encoding.
+
+ .. versionchanged:: 3.10
+ On Unix, the function now implements the Python UTF-8 Mode.
+
.. function:: dup(fd)