@@ -62,8 +62,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
62
62
'b' binary mode
63
63
't' text mode (default)
64
64
'+' open a disk file for updating (reading and writing)
65
- 'U' universal newline mode (for backwards compatibility; unneeded
66
- for new code)
65
+ 'U' universal newline mode (deprecated)
67
66
========= ===============================================================
68
67
69
68
The default mode is 'rt' (open for reading text). For binary random
@@ -79,6 +78,10 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
79
78
returned as strings, the bytes having been first decoded using a
80
79
platform-dependent encoding or using the specified encoding if given.
81
80
81
+ 'U' mode is deprecated and will raise an exception in future versions
82
+ of Python. It has no effect in Python 3. Use newline to control
83
+ universal newlines mode.
84
+
82
85
buffering is an optional integer used to set the buffering policy.
83
86
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
84
87
line buffering (only usable in text mode), and an integer > 1 to indicate
@@ -174,6 +177,9 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
174
177
if "U" in modes :
175
178
if creating or writing or appending :
176
179
raise ValueError ("can't use U and writing mode at once" )
180
+ import warnings
181
+ warnings .warn ("'U' mode is deprecated" ,
182
+ DeprecationWarning , 2 )
177
183
reading = True
178
184
if text and binary :
179
185
raise ValueError ("can't have text and binary mode at once" )
0 commit comments