Index: ps/trunk/libraries/source/spidermonkey/Fix-use-of-removed-U-support-in-python-3.11.patch =================================================================== --- ps/trunk/libraries/source/spidermonkey/Fix-use-of-removed-U-support-in-python-3.11.patch (nonexistent) +++ ps/trunk/libraries/source/spidermonkey/Fix-use-of-removed-U-support-in-python-3.11.patch (revision 27442) @@ -0,0 +1,130 @@ +From c6c6300e8698ba1d3db96591b9c150c49b8e6d76 Mon Sep 17 00:00:00 2001 +From: Ralph Sennhauser +Date: Fri, 13 Jan 2023 13:13:47 +0100 +Subject: [PATCH] Fix use of removed 'U' support in python 3.11 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Form https://docs.python.org/3.11/whatsnew/3.11.html: + +open(), io.open(), codecs.open() and fileinput.FileInput no longer +accept 'U' (“universal newline”) in the file mode. In Python 3, +“universal newline” mode is used by default whenever a file is opened in +text mode, and the 'U' flag has been deprecated since Python 3.3. The +newline parameter to these functions controls how universal newlines +work. (Contributed by Victor Stinner in bpo-37330.) + +https://github.com/python/cpython/issues/81511 +--- + 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 | 4 ++-- + python/mozbuild/mozpack/files.py | 4 ++-- + 5 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py +index f1d401ac2600..aca59d0f0517 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[a-z]+)(?:\s+(?P\S+)(?:\s+(?P\S+))?)?", re.U + ) +diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py +index 7bc1986d863b..b64a70946863 100644 +--- a/python/mozbuild/mozbuild/backend/base.py ++++ b/python/mozbuild/mozbuild/backend/base.py +@@ -272,7 +272,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 f7820b9c9147..857f1a6c9bfd 100644 +--- a/python/mozbuild/mozbuild/preprocessor.py ++++ b/python/mozbuild/mozbuild/preprocessor.py +@@ -531,7 +531,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() +@@ -860,7 +860,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: +@@ -914,7 +914,7 @@ class Preprocessor: + 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 071daecc397b..b59aabbea61b 100644 +--- a/python/mozbuild/mozbuild/util.py ++++ b/python/mozbuild/mozbuild/util.py +@@ -225,7 +225,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 +@@ -1447,7 +1447,7 @@ def patch_main(): + + def my_get_command_line(): + with open( +- os.path.join(os.path.dirname(__file__), "fork_interpose.py"), "rU" ++ os.path.join(os.path.dirname(__file__), "fork_interpose.py"), "r" + ) as fork_file: + fork_code = fork_file.read() + # Add our relevant globals. +diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py +index 8150e72d6fa2..001c497b2796 100644 +--- a/python/mozbuild/mozpack/files.py ++++ b/python/mozbuild/mozpack/files.py +@@ -574,7 +574,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) + +@@ -631,7 +631,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() +-- +2.38.2 + Index: ps/trunk/libraries/source/spidermonkey/patch.sh =================================================================== --- ps/trunk/libraries/source/spidermonkey/patch.sh (revision 27441) +++ ps/trunk/libraries/source/spidermonkey/patch.sh (revision 27442) @@ -1,34 +1,41 @@ #!/bin/sh set -e OS="${OS:=$(uname -s)}" # Apply patches if needed # This script gets called from build.sh. # The rust code is only linked if the JS Shell is enabled, # which fails now that rust is required in all cases. # https://bugzilla.mozilla.org/show_bug.cgi?id=1588340 patch -p1 < ../FixRustLinkage.diff # On windows, we need to differente debug/release library names. patch -p1 < ../FixWindowsLibNames.diff # There is an issue on 32-bit linux builds sometimes. # NB: the patch here is Comment 21 modified by Comment 25 # but that seems to imperfectly fix the issue with GCC. # It also won't compile on windows - in doubt, apply only where relevant. # https://bugzilla.mozilla.org/show_bug.cgi?id=1729459 if [ "$(uname -m)" = "i686" ] && [ "${OS}" != "Windows_NT" ] then patch -p1 < ../FixFpNormIssue.diff fi if [ "$OS" = "Darwin" ] then # The bundled virtualenv version is not working on MacOS # with recent homebrew and needs to be upgraded. # Install it locally to not pollute anything. pip3 install --upgrade -t virtualenv virtualenv export PYTHONPATH="$(pwd)/virtualenv:$PYTHONPATH" patch -p1 < ../FixVirtualEnv.diff fi + +# python 3.11 support +PYTHON_MINOR_VERSION="$(python3 -c 'import sys; print(sys.version_info.minor)')" +if [ "$PYTHON_MINOR_VERSION" -ge 11 ]; +then + patch -p1 < ../FixVirtualEnv.diff +fi