diff options
author | Victor Stinner <vstinner@python.org> | 2021-09-02 12:58:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-02 12:58:00 +0200 |
commit | 19ba2122ac7313ac29207360cfa864a275b9489e (patch) | |
tree | ab34611e2b6158889cabec93f76f40c71b6ea470 /Doc/library | |
parent | a8066087054417885db0a2dbdce2ddb2ac498247 (diff) | |
download | cpython-git-19ba2122ac7313ac29207360cfa864a275b9489e.tar.gz |
bpo-37330: open() no longer accept 'U' in file mode (GH-28118)
open(), io.open(), codecs.open() and fileinput.FileInput no longer
accept "U" ("universal newline") in the file mode. This flag was
deprecated since Python 3.3.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/codecs.rst | 3 | ||||
-rw-r--r-- | Doc/library/fileinput.rst | 8 | ||||
-rw-r--r-- | Doc/library/functions.rst | 25 |
3 files changed, 14 insertions, 22 deletions
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 0dcd88f9fd..9ea689acd8 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -204,6 +204,9 @@ wider range of codecs when working with binary files: *buffering* has the same meaning as for the built-in :func:`open` function. It defaults to -1 which means that the default buffer size will be used. + .. versionchanged:: 3.11 + The ``'U'`` mode has been removed. + .. function:: EncodedFile(file, data_encoding, file_encoding=None, errors='strict') diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst index 3880ed3d2b..9f7802dd45 100644 --- a/Doc/library/fileinput.rst +++ b/Doc/library/fileinput.rst @@ -153,7 +153,7 @@ available for subclassing as well: and :meth:`~io.TextIOBase.readline` cannot be mixed. With *mode* you can specify which file mode will be passed to :func:`open`. It - must be one of ``'r'``, ``'rU'``, ``'U'`` and ``'rb'``. + must be one of ``'r'`` and ``'rb'``. The *openhook*, when given, must be a function that takes two arguments, *filename* and *mode*, and returns an accordingly opened file-like object. You @@ -171,9 +171,6 @@ available for subclassing as well: .. versionchanged:: 3.2 Can be used as a context manager. - .. deprecated:: 3.4 - The ``'rU'`` and ``'U'`` modes. - .. deprecated:: 3.8 Support for :meth:`__getitem__` method is deprecated. @@ -183,6 +180,9 @@ available for subclassing as well: .. versionchanged:: 3.10 The keyword-only parameter *encoding* and *errors* are added. + .. versionchanged:: 3.11 + The ``'rU'`` and ``'U'`` modes have been removed. + **Optional in-place filtering:** if the keyword argument ``inplace=True`` is passed to :func:`fileinput.input` or to the :class:`FileInput` constructor, the diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 9629acec2b..a8fc7023d1 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1156,12 +1156,6 @@ are always available. They are listed here in alphabetical order. first decoded using a platform-dependent encoding or using the specified *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 behavior - in Python 3.0. Refer to the documentation of the - :ref:`newline <open-newline-parameter>` parameter for further details. - .. note:: Python doesn't depend on the underlying operating system's notion of text @@ -1304,8 +1298,7 @@ are always available. They are listed here in alphabetical order. The ``mode`` and ``flags`` arguments may have been modified or inferred from the original call. - .. versionchanged:: - 3.3 + .. versionchanged:: 3.3 * The *opener* parameter was added. * The ``'x'`` mode was added. @@ -1313,30 +1306,26 @@ are always available. They are listed here in alphabetical order. * :exc:`FileExistsError` is now raised if the file opened in exclusive creation mode (``'x'``) already exists. - .. versionchanged:: - 3.4 + .. versionchanged:: 3.4 * The file is now non-inheritable. - .. deprecated-removed:: 3.4 3.10 - - The ``'U'`` mode. - - .. versionchanged:: - 3.5 + .. versionchanged:: 3.5 * If the system call is interrupted and the signal handler does not raise an exception, the function now retries the system call instead of raising an :exc:`InterruptedError` exception (see :pep:`475` for the rationale). * The ``'namereplace'`` error handler was added. - .. versionchanged:: - 3.6 + .. versionchanged:: 3.6 * Support added to accept objects implementing :class:`os.PathLike`. * On Windows, opening a console buffer may return a subclass of :class:`io.RawIOBase` other than :class:`io.FileIO`. + .. versionchanged:: 3.11 + The ``'U'`` mode has been removed. + .. function:: ord(c) Given a string representing one Unicode character, return an integer |