Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e86d5b

Browse files
author
Victor Stinner
committed
Replace open(filename, 'rU') by open(filename, 'r')
The U flag is no more used (but still accepted for backward compatibility).
1 parent 35b300c commit 4e86d5b

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

Lib/pkgutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def _reopen(self):
248248
if self.file and self.file.closed:
249249
mod_type = self.etc[2]
250250
if mod_type==imp.PY_SOURCE:
251-
self.file = open(self.filename, 'rU')
251+
self.file = open(self.filename, 'r')
252252
elif mod_type in (imp.PY_COMPILED, imp.C_EXTENSION):
253253
self.file = open(self.filename, 'rb')
254254

@@ -293,7 +293,7 @@ def get_source(self, fullname=None):
293293
self.file.close()
294294
elif mod_type==imp.PY_COMPILED:
295295
if os.path.exists(self.filename[:-1]):
296-
f = open(self.filename[:-1], 'rU')
296+
f = open(self.filename[:-1], 'r')
297297
self.source = f.read()
298298
f.close()
299299
elif mod_type==imp.PKG_DIRECTORY:

Lib/runpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def _get_code_from_file(fname):
226226
code = read_code(f)
227227
if code is None:
228228
# That didn't work, so try it as normal source code
229-
with open(fname, "rU") as f:
229+
with open(fname, "r") as f:
230230
code = compile(f.read(), fname, 'exec')
231231
return code
232232

Lib/site.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def addpackage(sitedir, name, known_paths):
138138
reset = 0
139139
fullname = os.path.join(sitedir, name)
140140
try:
141-
f = open(fullname, "rU")
141+
f = open(fullname, "r")
142142
except IOError:
143143
return
144144
with f:
@@ -385,7 +385,7 @@ def __setup(self):
385385
for filename in self.__files:
386386
filename = os.path.join(dir, filename)
387387
try:
388-
fp = open(filename, "rU")
388+
fp = open(filename, "r")
389389
data = fp.read()
390390
fp.close()
391391
break

Lib/test/test_tarfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_fileobj_readlines(self):
8282
def test_fileobj_iter(self):
8383
self.tar.extract("ustar/regtype", TEMPDIR)
8484
tarinfo = self.tar.getmember("ustar/regtype")
85-
with open(os.path.join(TEMPDIR, "ustar/regtype"), "rU") as fobj1:
85+
with open(os.path.join(TEMPDIR, "ustar/regtype"), "r") as fobj1:
8686
lines1 = fobj1.readlines()
8787
fobj2 = self.tar.extractfile(tarinfo)
8888
try:

0 commit comments

Comments
 (0)