Fixup Python 3.11 build

This commit is contained in:
František Zatloukal 2022-07-24 11:39:13 +02:00
parent 4fd5a8aecb
commit 484fe87ff0
2 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,81 @@
From 95f1e91ef71d912be5f6dddb6fac68671d850fd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= <fzatlouk@redhat.com>
Date: Sun, 24 Jul 2022 11:11:01 +0200
Subject: [PATCH] Python/Build: Use r instead of rU file read modes
Fixes Python 3.11 build
---
python/mozbuild/mozbuild/action/process_define_files.py | 2 +-
python/mozbuild/mozbuild/preprocessor.py | 6 +++---
python/mozbuild/mozbuild/util.py | 4 +++-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py
index 6fff0d1..de2bcf4 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/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py
index 0e3a750..66f5cf7 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 044cf64..eb992ce 100644
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -54,6 +54,8 @@ def exec_(object, globals=None, locals=None):
def _open(path, mode):
+ if mode == "rU":
+ mode = "r"
if 'b' in mode:
return io.open(path, mode)
return io.open(path, mode, encoding='utf-8', newline='\n')
@@ -220,7 +222,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
--
2.37.1

View File

@ -30,7 +30,7 @@
Name: mozjs%{major}
Version: 78.15.0
Release: 4%{?dist}
Release: 5%{?dist}
Summary: SpiderMonkey JavaScript library
License: MPLv2.0 and MPLv1.1 and BSD and GPLv2+ and GPLv3+ and LGPLv2+ and AFL and ASL 2.0
@ -52,6 +52,8 @@ Patch13: Fixup-compatibility-of-mozbuild-with-Python-3.10.patch
Patch14: init_patch.patch
# TODO: Check with mozilla for cause of these fails and re-enable spidermonkey compile time checks if needed
Patch15: spidermonkey_checks_disable.patch
# Python 3.11 compat
Patch16: 0001-Python-Build-Use-r-instead-of-rU-file-read-modes.patch
# armv7 fixes
Patch17: definitions_for_user_vfp.patch
@ -128,6 +130,7 @@ pushd ../..
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%ifarch armv7hl
# Include definitions for user vfp on armv7 as it causes the compilation to fail without them
@ -286,6 +289,9 @@ PYTHONPATH=tests/lib %{__python3} jit-test/jit_test.py -s -t 1800 --no-progress
%{_includedir}/mozjs-%{major}/
%changelog
* Sun Jul 24 2022 Frantisek Zatloukal <fzatlouk@redhat.com> - 78.15.0-5
- Fixup Python 3.11 build
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 78.15.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild