Commits:
-
2e3559a1
by ahochheiden at 2023-01-30T16:22:58+00:00
Bug 1769631 - Remove 'U' from 'mode' parameters for various 'open' calls to ensure Python3.11 compatibility r=firefox-build-system-reviewers,glandium a=RyanVM
The 'U' flag represents "universal newline". It has been deprecated
since Python3.3. Since then "universal newline" is the default when a
file is opened in text mode (not bytes). In Python3.11 using the 'U'
flag throws errors. There should be no harm in removing 'U' from 'open'
everywhere it is used, and doing allows the use of Python3.11.
For more reading see: https://docs.python.org/3.11/whatsnew/3.11.html#changes-in-the-python-api
Differential Revision: https://phabricator.services.mozilla.com/D147721
(cherry picked from commit 3bc6973c9f883820d3a3b177263b79deeb51a61f)
6 changed files:
Changes:
dom/base/usecounters.py
... |
... |
@@ -8,7 +8,7 @@ import re |
8
|
8
|
|
9
|
9
|
def read_conf(conf_filename):
|
10
|
10
|
# Can't read/write from a single StringIO, so make a new one for reading.
|
11
|
|
- stream = open(conf_filename, "rU")
|
|
11
|
+ stream = open(conf_filename, "r")
|
12
|
12
|
|
13
|
13
|
def parse_counters(stream):
|
14
|
14
|
for line_num, line in enumerate(stream):
|
python/mozbuild/mozbuild/action/process_define_files.py
... |
... |
@@ -36,7 +36,7 @@ def process_define_file(output, input): |
36
|
36
|
) and not config.substs.get("JS_STANDALONE"):
|
37
|
37
|
config = PartialConfigEnvironment(mozpath.join(topobjdir, "js", "src"))
|
38
|
38
|
|
39
|
|
- with open(path, "rU") as input:
|
|
39
|
+ with open(path, "r") as input:
|
40
|
40
|
r = re.compile(
|
41
|
41
|
"^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
|
42
|
42
|
)
|
python/mozbuild/mozbuild/backend/base.py
... |
... |
@@ -272,7 +272,7 @@ class BuildBackend(LoggingMixin): |
272
|
272
|
return status
|
273
|
273
|
|
274
|
274
|
@contextmanager
|
275
|
|
- def _write_file(self, path=None, fh=None, readmode="rU"):
|
|
275
|
+ def _write_file(self, path=None, fh=None, readmode="r"):
|
276
|
276
|
"""Context manager to write a file.
|
277
|
277
|
|
278
|
278
|
This is a glorified wrapper around FileAvoidWrite with integration to
|
python/mozbuild/mozbuild/preprocessor.py
... |
... |
@@ -531,7 +531,7 @@ class Preprocessor: |
531
|
531
|
|
532
|
532
|
if args:
|
533
|
533
|
for f in args:
|
534
|
|
- with io.open(f, "rU", encoding="utf-8") as input:
|
|
534
|
+ with io.open(f, "r", encoding="utf-8") as input:
|
535
|
535
|
self.processFile(input=input, output=out)
|
536
|
536
|
if depfile:
|
537
|
537
|
mk = Makefile()
|
... |
... |
@@ -860,7 +860,7 @@ class Preprocessor: |
860
|
860
|
args = self.applyFilters(args)
|
861
|
861
|
if not os.path.isabs(args):
|
862
|
862
|
args = os.path.join(self.curdir, args)
|
863
|
|
- args = io.open(args, "rU", encoding="utf-8")
|
|
863
|
+ args = io.open(args, "r", encoding="utf-8")
|
864
|
864
|
except Preprocessor.Error:
|
865
|
865
|
raise
|
866
|
866
|
except Exception:
|
... |
... |
@@ -914,7 +914,7 @@ class Preprocessor: |
914
|
914
|
def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"):
|
915
|
915
|
pp = Preprocessor(defines=defines, marker=marker)
|
916
|
916
|
for f in includes:
|
917
|
|
- with io.open(f, "rU", encoding="utf-8") as input:
|
|
917
|
+ with io.open(f, "r", encoding="utf-8") as input:
|
918
|
918
|
pp.processFile(input=input, output=output)
|
919
|
919
|
return pp.includes
|
920
|
920
|
|
python/mozbuild/mozbuild/util.py
... |
... |
@@ -236,7 +236,7 @@ class FileAvoidWrite(BytesIO): |
236
|
236
|
still occur, as well as diff capture if requested.
|
237
|
237
|
"""
|
238
|
238
|
|
239
|
|
- def __init__(self, filename, capture_diff=False, dry_run=False, readmode="rU"):
|
|
239
|
+ def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"):
|
240
|
240
|
BytesIO.__init__(self)
|
241
|
241
|
self.name = filename
|
242
|
242
|
assert type(capture_diff) == bool
|
python/mozbuild/mozpack/files.py
... |
... |
@@ -554,7 +554,7 @@ class PreprocessedFile(BaseFile): |
554
|
554
|
pp = Preprocessor(defines=self.defines, marker=self.marker)
|
555
|
555
|
pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
|
556
|
556
|
|
557
|
|
- with _open(self.path, "rU") as input:
|
|
557
|
+ with _open(self.path, "r") as input:
|
558
|
558
|
with _open(os.devnull, "w") as output:
|
559
|
559
|
pp.processFile(input=input, output=output)
|
560
|
560
|
|
... |
... |
@@ -611,7 +611,7 @@ class PreprocessedFile(BaseFile): |
611
|
611
|
pp = Preprocessor(defines=self.defines, marker=self.marker)
|
612
|
612
|
pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
|
613
|
613
|
|
614
|
|
- with _open(self.path, "rU") as input:
|
|
614
|
+ with _open(self.path, "r") as input:
|
615
|
615
|
pp.processFile(input=input, output=dest, depfile=deps_out)
|
616
|
616
|
|
617
|
617
|
dest.close()
|
|