Skip to content

Commit

Permalink
Replace open(filename, 'rU') by open(filename, 'r')
Browse files Browse the repository at this point in the history
The U flag is no more used (but still accepted for backward compatibility).
  • Loading branch information
Victor Stinner committed May 4, 2011
1 parent 35b300c commit 4e86d5b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Lib/pkgutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _reopen(self):
if self.file and self.file.closed:
mod_type = self.etc[2]
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):
self.file = open(self.filename, 'rb')

Expand Down Expand Up @@ -293,7 +293,7 @@ def get_source(self, fullname=None):
self.file.close()
elif mod_type==imp.PY_COMPILED:
if os.path.exists(self.filename[:-1]):
f = open(self.filename[:-1], 'rU')
f = open(self.filename[:-1], 'r')
self.source = f.read()
f.close()
elif mod_type==imp.PKG_DIRECTORY:
Expand Down
2 changes: 1 addition & 1 deletion Lib/runpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _get_code_from_file(fname):
code = read_code(f)
if code is None:
# 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')
return code

Expand Down
4 changes: 2 additions & 2 deletions Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def addpackage(sitedir, name, known_paths):
reset = 0
fullname = os.path.join(sitedir, name)
try:
f = open(fullname, "rU")
f = open(fullname, "r")
except IOError:
return
with f:
Expand Down Expand Up @@ -385,7 +385,7 @@ def __setup(self):
for filename in self.__files:
filename = os.path.join(dir, filename)
try:
fp = open(filename, "rU")
fp = open(filename, "r")
data = fp.read()
fp.close()
break
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_fileobj_readlines(self):
def test_fileobj_iter(self):
self.tar.extract("ustar/regtype", TEMPDIR)
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()
fobj2 = self.tar.extractfile(tarinfo)
try:
Expand Down

0 comments on commit 4e86d5b

Please sign in to comment.