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:
Victor Stinner 2021-09-02 12:58:00 +02:00 committed by GitHub
parent a806608705
commit 19ba2122ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 61 additions and 104 deletions

View file

@ -226,7 +226,7 @@ def load_module(name, file, filename, details):
"""
suffix, mode, type_ = details
if mode and (not mode.startswith(('r', 'U')) or '+' in mode):
if mode and (not mode.startswith('r') or '+' in mode):
raise ValueError('invalid file open mode {!r}'.format(mode))
elif file is None and type_ in {PY_SOURCE, PY_COMPILED}:
msg = 'file object required for import (type code {})'.format(type_)