summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-04 17:50:22 (GMT)
committerGitHub <noreply@github.com>2020-03-04 17:50:22 (GMT)
commit942f7a2dea2e95a0fa848329565c0d0288d92e47 (patch)
tree31abda8d45ef676a46ea63a6a8a61ccf6061e9c5 /Doc
parent00c77ae55a82548a6b45af73cdf712ea34910645 (diff)
downloadcpython-942f7a2dea2e95a0fa848329565c0d0288d92e47.zip
cpython-942f7a2dea2e95a0fa848329565c0d0288d92e47.tar.gz
cpython-942f7a2dea2e95a0fa848329565c0d0288d92e47.tar.bz2
bpo-39674: Revert "bpo-37330: open() no longer accept 'U' in file mode (GH-16959)" (GH-18767)
This reverts commit e471e72977c83664f13d041c78549140c86c92de. The mode will be removed from Python 3.10.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/codecs.rst3
-rw-r--r--Doc/library/fileinput.rst9
-rw-r--r--Doc/library/functions.rst14
-rw-r--r--Doc/whatsnew/3.9.rst8
4 files changed, 15 insertions, 19 deletions
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index ec6a053..f071057 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -197,9 +197,6 @@ 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.9
- 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 236f5d5..cc4039a 100644
--- a/Doc/library/fileinput.rst
+++ b/Doc/library/fileinput.rst
@@ -148,8 +148,8 @@ available for subclassing as well:
The sequence must be accessed in strictly sequential order; random access
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 ``'r'`` or ``'rb'``.
+ With *mode* you can specify which file mode will be passed to :func:`open`. It
+ must be one of ``'r'``, ``'rU'``, ``'U'`` 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
@@ -166,14 +166,15 @@ 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.
.. versionchanged:: 3.8
The keyword parameter *mode* and *openhook* are now keyword-only.
- .. versionchanged:: 3.9
- The ``'rU'`` and ``'U'`` modes have been removed.
**Optional in-place filtering:** if the keyword argument ``inplace=True`` is
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index cc48597..ca09e6f 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1090,6 +1090,12 @@ 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 behaviour
+ 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
@@ -1246,6 +1252,10 @@ are always available. They are listed here in alphabetical order.
* The file is now non-inheritable.
+ .. deprecated-removed:: 3.4 3.10
+
+ The ``'U'`` mode.
+
.. versionchanged::
3.5
@@ -1261,10 +1271,6 @@ are always available. They are listed here in alphabetical order.
* On Windows, opening a console buffer may return a subclass of
:class:`io.RawIOBase` other than :class:`io.FileIO`.
- .. versionchanged:: 3.9
- The ``'U'`` mode has been removed.
-
-
.. function:: ord(c)
Given a string representing one Unicode character, return an integer
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index d072b8d..a59de48 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -625,14 +625,6 @@ that may require changes to your code.
Changes in the Python API
-------------------------
-* :func:`open`, :func:`io.open`, :func:`codecs.open` and
- :class:`fileinput.FileInput` no longer accept ``'U'`` ("universal newline")
- in the file mode. This flag was deprecated since Python 3.3. In Python 3, the
- "universal newline" is used by default when a file is open in text mode. The
- :ref:`newline parameter <open-newline-parameter>` of :func:`open` controls
- how universal newlines works.
- (Contributed by Victor Stinner in :issue:`37330`.)
-
* :func:`__import__` and :func:`importlib.util.resolve_name` now raise
:exc:`ImportError` where it previously raised :exc:`ValueError`. Callers
catching the specific exception type and supporting both Python 3.9 and