summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-09-02 10:58:00 (GMT)
committerGitHub <noreply@github.com>2021-09-02 10:58:00 (GMT)
commit19ba2122ac7313ac29207360cfa864a275b9489e (patch)
treeab34611e2b6158889cabec93f76f40c71b6ea470 /Lib/_pyio.py
parenta8066087054417885db0a2dbdce2ddb2ac498247 (diff)
downloadcpython-19ba2122ac7313ac29207360cfa864a275b9489e.zip
cpython-19ba2122ac7313ac29207360cfa864a275b9489e.tar.gz
cpython-19ba2122ac7313ac29207360cfa864a275b9489e.tar.bz2
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 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py14
1 files changed, 1 insertions, 13 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 56e9a0c..d711974 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -101,7 +101,6 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
'b' binary mode
't' text mode (default)
'+' open a disk file for updating (reading and writing)
- 'U' universal newline mode (deprecated)
========= ===============================================================
The default mode is 'rt' (open for reading text). For binary random
@@ -117,10 +116,6 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
returned as strings, the bytes having been first decoded using a
platform-dependent encoding or using the specified encoding if given.
- 'U' mode is deprecated and will raise an exception in future versions
- of Python. It has no effect in Python 3. Use newline to control
- universal newlines mode.
-
buffering is an optional integer used to set the buffering policy.
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
line buffering (only usable in text mode), and an integer > 1 to indicate
@@ -206,7 +201,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
if errors is not None and not isinstance(errors, str):
raise TypeError("invalid errors: %r" % errors)
modes = set(mode)
- if modes - set("axrwb+tU") or len(mode) > len(modes):
+ if modes - set("axrwb+t") or len(mode) > len(modes):
raise ValueError("invalid mode: %r" % mode)
creating = "x" in modes
reading = "r" in modes
@@ -215,13 +210,6 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
updating = "+" in modes
text = "t" in modes
binary = "b" in modes
- if "U" in modes:
- if creating or writing or appending or updating:
- raise ValueError("mode U cannot be combined with 'x', 'w', 'a', or '+'")
- import warnings
- warnings.warn("'U' mode is deprecated",
- DeprecationWarning, 2)
- reading = True
if text and binary:
raise ValueError("can't have text and binary mode at once")
if creating + reading + writing + appending > 1: