[Python-checkins] cpython: Replace open(filename, 'rU') by open(filename, 'r')

victor.stinner python-checkins at python.org
Wed May 4 13:55:47 CEST 2011


http://hg.python.org/cpython/rev/be5b8d1ded34
changeset:   69823:be5b8d1ded34
parent:      69821:a5890ff5e3d5
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Wed May 04 13:55:36 2011 +0200
summary:
  Replace open(filename, 'rU') by open(filename, 'r')

The U flag is no more used (but still accepted for backward compatibility).

files:
  Lib/pkgutil.py           |  4 ++--
  Lib/runpy.py             |  2 +-
  Lib/site.py              |  4 ++--
  Lib/test/test_tarfile.py |  2 +-
  4 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -248,7 +248,7 @@
         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')
 
@@ -293,7 +293,7 @@
                     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:
diff --git a/Lib/runpy.py b/Lib/runpy.py
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -226,7 +226,7 @@
         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
 
diff --git a/Lib/site.py b/Lib/site.py
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -138,7 +138,7 @@
         reset = 0
     fullname = os.path.join(sitedir, name)
     try:
-        f = open(fullname, "rU")
+        f = open(fullname, "r")
     except IOError:
         return
     with f:
@@ -385,7 +385,7 @@
             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
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -82,7 +82,7 @@
     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:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list