mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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.
This commit is contained in:
parent
a806608705
commit
19ba2122ac
13 changed files with 61 additions and 104 deletions
|
@ -217,15 +217,10 @@ class FileInput:
|
|||
EncodingWarning, 2)
|
||||
|
||||
# restrict mode argument to reading modes
|
||||
if mode not in ('r', 'rU', 'U', 'rb'):
|
||||
raise ValueError("FileInput opening mode must be one of "
|
||||
"'r', 'rU', 'U' and 'rb'")
|
||||
if 'U' in mode:
|
||||
import warnings
|
||||
warnings.warn("'U' mode is deprecated",
|
||||
DeprecationWarning, 2)
|
||||
if mode not in ('r', 'rb'):
|
||||
raise ValueError("FileInput opening mode must be 'r' or 'rb'")
|
||||
self._mode = mode
|
||||
self._write_mode = mode.replace('r', 'w') if 'U' not in mode else 'w'
|
||||
self._write_mode = mode.replace('r', 'w')
|
||||
if openhook:
|
||||
if inplace:
|
||||
raise ValueError("FileInput cannot use an opening hook in inplace mode")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue