mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Replace open(filename, 'rU') by open(filename, 'r')
The U flag is no more used (but still accepted for backward compatibility).
This commit is contained in:
parent
35b300c5fd
commit
4e86d5b88d
4 changed files with 6 additions and 6 deletions
|
@ -248,7 +248,7 @@ class ImpLoader:
|
||||||
if self.file and self.file.closed:
|
if self.file and self.file.closed:
|
||||||
mod_type = self.etc[2]
|
mod_type = self.etc[2]
|
||||||
if mod_type==imp.PY_SOURCE:
|
if mod_type==imp.PY_SOURCE:
|
||||||
self.file = open(self.filename, 'rU')
|
self.file = open(self.filename, 'r')
|
||||||
elif mod_type in (imp.PY_COMPILED, imp.C_EXTENSION):
|
elif mod_type in (imp.PY_COMPILED, imp.C_EXTENSION):
|
||||||
self.file = open(self.filename, 'rb')
|
self.file = open(self.filename, 'rb')
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ class ImpLoader:
|
||||||
self.file.close()
|
self.file.close()
|
||||||
elif mod_type==imp.PY_COMPILED:
|
elif mod_type==imp.PY_COMPILED:
|
||||||
if os.path.exists(self.filename[:-1]):
|
if os.path.exists(self.filename[:-1]):
|
||||||
f = open(self.filename[:-1], 'rU')
|
f = open(self.filename[:-1], 'r')
|
||||||
self.source = f.read()
|
self.source = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
elif mod_type==imp.PKG_DIRECTORY:
|
elif mod_type==imp.PKG_DIRECTORY:
|
||||||
|
|
|
@ -226,7 +226,7 @@ def _get_code_from_file(fname):
|
||||||
code = read_code(f)
|
code = read_code(f)
|
||||||
if code is None:
|
if code is None:
|
||||||
# That didn't work, so try it as normal source code
|
# That didn't work, so try it as normal source code
|
||||||
with open(fname, "rU") as f:
|
with open(fname, "r") as f:
|
||||||
code = compile(f.read(), fname, 'exec')
|
code = compile(f.read(), fname, 'exec')
|
||||||
return code
|
return code
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ def addpackage(sitedir, name, known_paths):
|
||||||
reset = 0
|
reset = 0
|
||||||
fullname = os.path.join(sitedir, name)
|
fullname = os.path.join(sitedir, name)
|
||||||
try:
|
try:
|
||||||
f = open(fullname, "rU")
|
f = open(fullname, "r")
|
||||||
except IOError:
|
except IOError:
|
||||||
return
|
return
|
||||||
with f:
|
with f:
|
||||||
|
@ -385,7 +385,7 @@ class _Printer(object):
|
||||||
for filename in self.__files:
|
for filename in self.__files:
|
||||||
filename = os.path.join(dir, filename)
|
filename = os.path.join(dir, filename)
|
||||||
try:
|
try:
|
||||||
fp = open(filename, "rU")
|
fp = open(filename, "r")
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
fp.close()
|
fp.close()
|
||||||
break
|
break
|
||||||
|
|
|
@ -82,7 +82,7 @@ class UstarReadTest(ReadTest):
|
||||||
def test_fileobj_iter(self):
|
def test_fileobj_iter(self):
|
||||||
self.tar.extract("ustar/regtype", TEMPDIR)
|
self.tar.extract("ustar/regtype", TEMPDIR)
|
||||||
tarinfo = self.tar.getmember("ustar/regtype")
|
tarinfo = self.tar.getmember("ustar/regtype")
|
||||||
with open(os.path.join(TEMPDIR, "ustar/regtype"), "rU") as fobj1:
|
with open(os.path.join(TEMPDIR, "ustar/regtype"), "r") as fobj1:
|
||||||
lines1 = fobj1.readlines()
|
lines1 = fobj1.readlines()
|
||||||
fobj2 = self.tar.extractfile(tarinfo)
|
fobj2 = self.tar.extractfile(tarinfo)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue