@@ -62,8 +62,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
6262 'b' binary mode
6363 't' text mode (default)
6464 '+' 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)
6766 ========= ===============================================================
6867
6968 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,
7978 returned as strings, the bytes having been first decoded using a
8079 platform-dependent encoding or using the specified encoding if given.
8180
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+
8285 buffering is an optional integer used to set the buffering policy.
8386 Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
8487 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,
174177 if "U" in modes :
175178 if creating or writing or appending :
176179 raise ValueError ("can't use U and writing mode at once" )
180+ import warnings
181+ warnings .warn ("'U' mode is deprecated" ,
182+ DeprecationWarning , 2 )
177183 reading = True
178184 if text and binary :
179185 raise ValueError ("can't have text and binary mode at once" )
0 commit comments