void-packages/srcpkgs/mozjs102/patches/python-3.11.patch

131 lines
5.9 KiB
Diff
Raw Normal View History

2022-09-11 18:58:40 +02:00
From 964834abba3b093385409f1d594835ad94362def Mon Sep 17 00:00:00 2001
From: ahochheiden <ahochheiden@mozilla.com>
Date: Thu, 2 Jun 2022 06:27:44 +0000
Subject: [PATCH] Bug 1769631 - Remove 'U' from 'mode' parameters for various
'open' calls to ensure Python3.11 compatibility
r=firefox-build-system-reviewers,glandium
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
---
dom/base/usecounters.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/mozpack/files.py | 4 ++--
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dom/base/usecounters.py b/dom/base/usecounters.py
index 780e3b32b2131..7e2c7148ece55 100644
--- a/dom/base/usecounters.py
+++ b/dom/base/usecounters.py
@@ -8,7 +8,7 @@
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/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py
index f1d401ac26006..aca59d0f05177 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):
) and 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
)
diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py
index 7bc1986d863b5..b64a70946863d 100644
--- a/python/mozbuild/mozbuild/backend/base.py
+++ b/python/mozbuild/mozbuild/backend/base.py
@@ -272,7 +272,7 @@ def post_build(self, config, output, jobs, verbose, status):
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 f7820b9c91473..857f1a6c9bfd1 100644
--- a/python/mozbuild/mozbuild/preprocessor.py
+++ b/python/mozbuild/mozbuild/preprocessor.py
@@ -531,7 +531,7 @@ def get_output_file(path, encoding=None):
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()
@@ -860,7 +860,7 @@ def do_include(self, args, filters=True):
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:
@@ -914,7 +914,7 @@ def do_error(self, args):
def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"):
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 b09f1646988f0..4f1e0cdc5f568 100644
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -236,7 +236,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/mozpack/files.py b/python/mozbuild/mozpack/files.py
index 1d8a1ed2d8a7e..a295a67b5a34f 100644
--- a/python/mozbuild/mozpack/files.py
+++ b/python/mozbuild/mozpack/files.py
@@ -554,7 +554,7 @@ def inputs(self):
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)
@@ -611,7 +611,7 @@ def copy(self, dest, skip_if_older=True):
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()