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(-)
@@ -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)
@@ -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)
@@ -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()
@@ -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:
@@ -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):
@@ -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)
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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]
@@ -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()
@@ -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()
@@ -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'
@@ -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:
@@ -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'
@@ -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