b2fc4c6d创建于 2024年4月6日历史提交
From bb32690d45fa08c00464c510d3b5dee100f0dd3a Mon Sep 17 00:00:00 2001
From: zhanghan <zhanghan@kylinos.cn>
Date: Mon, 21 Aug 2023 13:48:20 +0800
Subject: [PATCH] modify mode rU to r

---
 build/pymake/mkformat.py                                    | 2 +-
 build/pymake/mkparse.py                                     | 2 +-
 build/pymake/pymake/parser.py                               | 2 +-
 build/pymake/tests/formattingtests.py                       | 2 +-
 dom/base/usecounters.py                                     | 2 +-
 media/webrtc/trunk/webrtc/build/gyp_helper.py               | 2 +-
 python/mozbuild/mozbuild/action/process_define_files.py     | 2 +-
 python/mozbuild/mozbuild/backend/base.py                    | 2 +-
 python/mozbuild/mozbuild/preprocessor.py                    | 6 +++---
 python/mozbuild/mozbuild/util.py                            | 2 +-
 python/mozbuild/mozbuild/virtualenv.py                      | 2 +-
 python/mozbuild/mozpack/files.py                            | 4 ++--
 .../tests/conformance-checkers/tools/build-svg-tests.py     | 2 +-
 .../tests/tools/third_party/py/py/_path/common.py           | 2 +-
 .../tests/tools/third_party/py/py/_path/svnurl.py           | 2 +-
 third_party/python/py/py/_path/common.py                    | 2 +-
 third_party/python/py/py/_path/svnurl.py                    | 2 +-
 17 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/build/pymake/mkformat.py b/build/pymake/mkformat.py
index 41dd761b2f..d33151172c 100755
--- a/build/pymake/mkformat.py
+++ b/build/pymake/mkformat.py
@@ -6,7 +6,7 @@ import pymake.parser
 filename = sys.argv[1]
 source = None
 
-with open(filename, 'rU') as fh:
+with open(filename, 'r') as fh:
     source = fh.read()
 
 statements = pymake.parser.parsestring(source, filename)
diff --git a/build/pymake/mkparse.py b/build/pymake/mkparse.py
index 253683948a..3ebbc089fe 100755
--- a/build/pymake/mkparse.py
+++ b/build/pymake/mkparse.py
@@ -5,7 +5,7 @@ import pymake.parser
 
 for f in sys.argv[1:]:
     print "Parsing %s" % f
-    fd = open(f, 'rU')
+    fd = open(f, 'r')
     s = fd.read()
     fd.close()
     stmts = pymake.parser.parsestring(s, f)
diff --git a/build/pymake/pymake/parser.py b/build/pymake/pymake/parser.py
index 4bff533688..3119a10a10 100644
--- a/build/pymake/pymake/parser.py
+++ b/build/pymake/pymake/parser.py
@@ -347,7 +347,7 @@ _directivesre = re.compile(r'(%s)(?:$|\s+)' % '|'.join(_directivestokenlist))
 _varsettokens = (':=', '+=', '?=', '=')
 
 def _parsefile(pathname):
-    fd = open(pathname, "rU")
+    fd = open(pathname, "r")
     stmts = parsestring(fd.read(), pathname)
     stmts.mtime = os.fstat(fd.fileno()).st_mtime
     fd.close()
diff --git a/build/pymake/tests/formattingtests.py b/build/pymake/tests/formattingtests.py
index 7aad6d4cc1..282ef02414 100644
--- a/build/pymake/tests/formattingtests.py
+++ b/build/pymake/tests/formattingtests.py
@@ -253,7 +253,7 @@ class MakefileCorupusTest(TestBase):
                 continue
 
             source = None
-            with open(makefile, 'rU') as fh:
+            with open(makefile, 'r') as fh:
                 source = fh.read()
 
             try:
diff --git a/dom/base/usecounters.py b/dom/base/usecounters.py
index fdcd366232..026a647c51 100644
--- a/dom/base/usecounters.py
+++ b/dom/base/usecounters.py
@@ -10,7 +10,7 @@ import sys
 
 def read_conf(conf_filename):
     # Can't read/write from a single StringIO, so make a new one for reading.
-    stream = open(conf_filename, 'rU')
+    stream = open(conf_filename, 'r')
 
     def parse_counters(stream):
         for line_num, line in enumerate(stream):
diff --git a/media/webrtc/trunk/webrtc/build/gyp_helper.py b/media/webrtc/trunk/webrtc/build/gyp_helper.py
index c840f2d6dc..42f6400a91 100644
--- a/media/webrtc/trunk/webrtc/build/gyp_helper.py
+++ b/media/webrtc/trunk/webrtc/build/gyp_helper.py
@@ -15,7 +15,7 @@ def apply_gyp_environment_from_file(file_path):
   """Reads in a *.gyp_env file and applies the valid keys to os.environ."""
   if not os.path.exists(file_path):
     return
-  with open(file_path, 'rU') as f:
+  with open(file_path, 'r') as f:
     file_contents = f.read()
   try:
     file_data = eval(file_contents, {'__builtins__': None}, None)
diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py
index 6fff0d1d64..de2bcf4fc2 100644
--- a/python/mozbuild/mozbuild/action/process_define_files.py
+++ b/python/mozbuild/mozbuild/action/process_define_files.py
@@ -36,7 +36,7 @@ def process_define_file(output, input):
             not config.substs.get('JS_STANDALONE'):
         config = PartialConfigEnvironment(mozpath.join(topobjdir, 'js', 'src'))
 
-    with open(path, 'rU') as input:
+    with open(path, 'r') as input:
         r = re.compile('^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?', re.U)
         for l in input:
             m = r.match(l)
diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py
index 367fe160bc..51cee16bd6 100644
--- a/python/mozbuild/mozbuild/backend/base.py
+++ b/python/mozbuild/mozbuild/backend/base.py
@@ -265,7 +265,7 @@ class BuildBackend(LoggingMixin):
         return status
 
     @contextmanager
-    def _write_file(self, path=None, fh=None, readmode='rU'):
+    def _write_file(self, path=None, fh=None, readmode='r'):
         """Context manager to write a file.
 
         This is a glorified wrapper around FileAvoidWrite with integration to
diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py
index 0e3a750e73..66f5cf7254 100644
--- a/python/mozbuild/mozbuild/preprocessor.py
+++ b/python/mozbuild/mozbuild/preprocessor.py
@@ -517,7 +517,7 @@ class Preprocessor:
 
         if args:
             for f in args:
-                with io.open(f, 'rU', encoding='utf-8') as input:
+                with io.open(f, 'r', encoding='utf-8') as input:
                     self.processFile(input=input, output=out)
             if depfile:
                 mk = Makefile()
@@ -807,7 +807,7 @@ class Preprocessor:
                     args = self.applyFilters(args)
                 if not os.path.isabs(args):
                     args = os.path.join(self.curdir, args)
-                args = io.open(args, 'rU', encoding='utf-8')
+                args = io.open(args, 'r', encoding='utf-8')
             except Preprocessor.Error:
                 raise
             except Exception:
@@ -862,7 +862,7 @@ def preprocess(includes=[sys.stdin], defines={},
     pp = Preprocessor(defines=defines,
                       marker=marker)
     for f in includes:
-        with io.open(f, 'rU', encoding='utf-8') as input:
+        with io.open(f, 'r', encoding='utf-8') as input:
             pp.processFile(input=input, output=output)
     return pp.includes
 
diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py
index 98ed3ef521..535eda5c25 100644
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -220,7 +220,7 @@ class FileAvoidWrite(BytesIO):
     still occur, as well as diff capture if requested.
     """
 
-    def __init__(self, filename, capture_diff=False, dry_run=False, readmode='rU'):
+    def __init__(self, filename, capture_diff=False, dry_run=False, readmode='r'):
         BytesIO.__init__(self)
         self.name = filename
         assert type(capture_diff) == bool
diff --git a/python/mozbuild/mozbuild/virtualenv.py b/python/mozbuild/mozbuild/virtualenv.py
index f331c48554..e647375bb3 100644
--- a/python/mozbuild/mozbuild/virtualenv.py
+++ b/python/mozbuild/mozbuild/virtualenv.py
@@ -257,7 +257,7 @@ class VirtualenvManager(object):
         return self.virtualenv_root
 
     def packages(self):
-        mode = 'rU' if PY2 else 'r'
+        mode = 'r' if PY2 else 'r'
         with open(self.manifest_path, mode) as fh:
             packages = [line.rstrip().split(':')
                         for line in fh]
diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py
index ad0f7c2aab..fa353e89f8 100644
--- a/python/mozbuild/mozpack/files.py
+++ b/python/mozbuild/mozpack/files.py
@@ -558,7 +558,7 @@ class PreprocessedFile(BaseFile):
         pp = Preprocessor(defines=self.defines, marker=self.marker)
         pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
 
-        with _open(self.path, 'rU') as input:
+        with _open(self.path, 'r') as input:
             with _open(os.devnull, 'w') as output:
                 pp.processFile(input=input, output=output)
 
@@ -615,7 +615,7 @@ class PreprocessedFile(BaseFile):
         pp = Preprocessor(defines=self.defines, marker=self.marker)
         pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
 
-        with _open(self.path, 'rU') as input:
+        with _open(self.path, 'r') as input:
             pp.processFile(input=input, output=dest, depfile=deps_out)
 
         dest.close()
diff --git a/testing/web-platform/tests/conformance-checkers/tools/build-svg-tests.py b/testing/web-platform/tests/conformance-checkers/tools/build-svg-tests.py
index dd3aa3844e..85bfbcff5d 100644
--- a/testing/web-platform/tests/conformance-checkers/tools/build-svg-tests.py
+++ b/testing/web-platform/tests/conformance-checkers/tools/build-svg-tests.py
@@ -139,7 +139,7 @@ def build_html_test_file(filename, svgdirectory, htmldirectory):
     logging.debug(htmlpathname)
 
     # read SVG data
-    svgfile = open(svgpathname, "rU")
+    svgfile = open(svgpathname, "r")
     svg = svgfile.read()
     svgfile.close()
 
diff --git a/testing/web-platform/tests/tools/third_party/py/py/_path/common.py b/testing/web-platform/tests/tools/third_party/py/py/_path/common.py
index 2d490b56a8..06ced4807a 100644
--- a/testing/web-platform/tests/tools/third_party/py/py/_path/common.py
+++ b/testing/web-platform/tests/tools/third_party/py/py/_path/common.py
@@ -174,7 +174,7 @@ class PathBase(object):
         """ read and return a list of lines from the path. if cr is False, the
 newline will be removed from the end of each line. """
         if sys.version_info < (3, ):
-            mode = 'rU'
+            mode = 'r'
         else:  # python 3 deprecates mode "U" in favor of "newline" option
             mode = 'r'
 
diff --git a/testing/web-platform/tests/tools/third_party/py/py/_path/svnurl.py b/testing/web-platform/tests/tools/third_party/py/py/_path/svnurl.py
index 6589a71d09..da49ff6ac0 100644
--- a/testing/web-platform/tests/tools/third_party/py/py/_path/svnurl.py
+++ b/testing/web-platform/tests/tools/third_party/py/py/_path/svnurl.py
@@ -97,7 +97,7 @@ class SvnCommandPath(svncommon.SvnPathBase):
 
     def open(self, mode='r'):
         """ return an opened file with the given mode. """
-        if mode not in ("r", "rU",):
+        if mode not in ("r", "r",):
             raise ValueError("mode %r not supported" % (mode,))
         assert self.check(file=1) # svn cat returns an empty file otherwise
         if self.rev is None:
diff --git a/third_party/python/py/py/_path/common.py b/third_party/python/py/py/_path/common.py
index 2d490b56a8..06ced4807a 100644
--- a/third_party/python/py/py/_path/common.py
+++ b/third_party/python/py/py/_path/common.py
@@ -174,7 +174,7 @@ class PathBase(object):
         """ read and return a list of lines from the path. if cr is False, the
 newline will be removed from the end of each line. """
         if sys.version_info < (3, ):
-            mode = 'rU'
+            mode = 'r'
         else:  # python 3 deprecates mode "U" in favor of "newline" option
             mode = 'r'
 
diff --git a/third_party/python/py/py/_path/svnurl.py b/third_party/python/py/py/_path/svnurl.py
index 6589a71d09..da49ff6ac0 100644
--- a/third_party/python/py/py/_path/svnurl.py
+++ b/third_party/python/py/py/_path/svnurl.py
@@ -97,7 +97,7 @@ class SvnCommandPath(svncommon.SvnPathBase):
 
     def open(self, mode='r'):
         """ return an opened file with the given mode. """
-        if mode not in ("r", "rU",):
+        if mode not in ("r", "r",):
             raise ValueError("mode %r not supported" % (mode,))
         assert self.check(file=1) # svn cat returns an empty file otherwise
         if self.rev is None:
-- 
2.33.0