Issue #15204: Deprecated the 'U' mode in file-like objects.

This commit is contained in:
Serhiy Storchaka 2013-11-23 22:12:06 +02:00
parent d41c343f28
commit 6787a3806e
13 changed files with 45 additions and 13 deletions

View file

@ -103,7 +103,7 @@ def source_from_cache(path):
def get_suffixes():
"""**DEPRECATED**"""
extensions = [(s, 'rb', C_EXTENSION) for s in machinery.EXTENSION_SUFFIXES]
source = [(s, 'U', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
source = [(s, 'r', PY_SOURCE) for s in machinery.SOURCE_SUFFIXES]
bytecode = [(s, 'rb', PY_COMPILED) for s in machinery.BYTECODE_SUFFIXES]
return extensions + source + bytecode
@ -297,7 +297,7 @@ def find_module(name, path=None):
raise ImportError(_ERR_MSG.format(name), name=name)
encoding = None
if mode == 'U':
if 'b' not in mode:
with open(file_path, 'rb') as file:
encoding = tokenize.detect_encoding(file.readline)[0]
file = open(file_path, mode, encoding=encoding)