Clarify U-mode deprecation in open() (GH-11646)
The previous wording could be read as saying that universal
newlines mode itself was deprecated, when it's only the 'U'
character in the mode field that should be avoided.
The update also moves the description of the 'U' mode character
out of the mode table, as the longer explanation was overly
intrusive as a table entry and overshadowed the actually useful
mode characters.
(cherry picked from commit 3171df3414
)
Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
This commit is contained in:
parent
b2b023c657
commit
658ff84496
|
@ -997,7 +997,6 @@ are always available. They are listed here in alphabetical order.
|
||||||
``'b'`` binary mode
|
``'b'`` binary mode
|
||||||
``'t'`` text mode (default)
|
``'t'`` text mode (default)
|
||||||
``'+'`` open a disk file for updating (reading and writing)
|
``'+'`` open a disk file for updating (reading and writing)
|
||||||
``'U'`` :term:`universal newlines` mode (deprecated)
|
|
||||||
========= ===============================================================
|
========= ===============================================================
|
||||||
|
|
||||||
The default mode is ``'r'`` (open for reading text, synonym of ``'rt'``).
|
The default mode is ``'r'`` (open for reading text, synonym of ``'rt'``).
|
||||||
|
@ -1012,6 +1011,12 @@ are always available. They are listed here in alphabetical order.
|
||||||
first decoded using a platform-dependent encoding or using the specified
|
first decoded using a platform-dependent encoding or using the specified
|
||||||
*encoding* if given.
|
*encoding* if given.
|
||||||
|
|
||||||
|
There is an additional mode character permitted, ``'U'``, which no longer
|
||||||
|
has any effect, and is considered deprecated. It previously enabled
|
||||||
|
:term:`universal newlines` in text mode, which became the default behaviour
|
||||||
|
in Python 3.0. Refer to the documentation of the
|
||||||
|
:ref:`newline <open-newline-parameter>` parameter for further details.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Python doesn't depend on the underlying operating system's notion of text
|
Python doesn't depend on the underlying operating system's notion of text
|
||||||
|
@ -1078,6 +1083,8 @@ are always available. They are listed here in alphabetical order.
|
||||||
.. index::
|
.. index::
|
||||||
single: universal newlines; open() built-in function
|
single: universal newlines; open() built-in function
|
||||||
|
|
||||||
|
.. _open-newline-parameter:
|
||||||
|
|
||||||
*newline* controls how :term:`universal newlines` mode works (it only
|
*newline* controls how :term:`universal newlines` mode works (it only
|
||||||
applies to text mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and
|
applies to text mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and
|
||||||
``'\r\n'``. It works as follows:
|
``'\r\n'``. It works as follows:
|
||||||
|
|
Loading…
Reference in New Issue