Fix f37 FTBFS Python 3.11 API incompatibilities

Python 3.11 "ValueError: invalid mode: 'rU'"
'U' is deprecated since Python 3 and default, error with Python 3.11
Remove 'U' from '"rU"' to '"r"'.

Python 3.11 "Invalid regular expression for rule '...'.
global flags not at the start of the expression at position ...
Change global inline flags (?s)... to local inline flags (?s:...)

See
https://docs.python.org/3.11/whatsnew/3.11.html#changes-in-the-python-api

* open(), io.open(), codecs.open() and fileinput.FileInput no
  longer accept 'U' (“universal newline”) in the file mode. This
  flag was deprecated since Python 3.3. In Python 3, the
  “universal newline” is used by default when a file is open in
  text mode.

* Global inline flags (e.g. (?i)) can now only be used at the
  start of the regular expressions. Using them not at the start of
  expression was deprecated since Python 3.6.
This commit is contained in:
Eike Rathke 2022-07-12 11:51:38 +02:00
parent 600e3321f0
commit 3ec1ca4ba3
3 changed files with 139 additions and 1 deletions

102
python3.11-open-U.patch Normal file
View File

@ -0,0 +1,102 @@
--- thunderbird-91.11.0/dom/base/usecounters.py.python-open-U 2022-06-28 04:37:00.000000000 +0200
+++ thunderbird-91.11.0/dom/base/usecounters.py 2022-07-11 19:17:46.266517761 +0200
@@ -8,7 +8,7 @@ import re
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):
--- thunderbird-91.11.0/python/mozbuild/mozbuild/action/process_define_files.py.python-open-U 2022-06-28 04:37:39.000000000 +0200
+++ thunderbird-91.11.0/python/mozbuild/mozbuild/action/process_define_files.py 2022-07-11 19:18:24.056417112 +0200
@@ -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
)
--- thunderbird-91.11.0/python/mozbuild/mozbuild/backend/base.py.python-open-U 2022-06-28 04:37:39.000000000 +0200
+++ thunderbird-91.11.0/python/mozbuild/mozbuild/backend/base.py 2022-07-11 19:18:34.165390187 +0200
@@ -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
--- thunderbird-91.11.0/python/mozbuild/mozbuild/preprocessor.py.python-open-U 2022-06-28 04:37:20.000000000 +0200
+++ thunderbird-91.11.0/python/mozbuild/mozbuild/preprocessor.py 2022-07-11 19:19:30.677239685 +0200
@@ -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
--- thunderbird-91.11.0/python/mozbuild/mozbuild/util.py.python-open-U 2022-06-28 04:37:40.000000000 +0200
+++ thunderbird-91.11.0/python/mozbuild/mozbuild/util.py 2022-07-11 19:19:19.903268374 +0200
@@ -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.
--- thunderbird-91.11.0/python/mozbuild/mozpack/files.py.python-open-U 2022-06-28 04:37:40.000000000 +0200
+++ thunderbird-91.11.0/python/mozbuild/mozpack/files.py 2022-07-11 19:19:40.372213866 +0200
@@ -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()

View File

@ -0,0 +1,27 @@
--- thunderbird-91.11.0/xpcom/idl-parser/xpidl/xpidl.py.python-inline-flags 2022-06-28 04:39:56.000000000 +0200
+++ thunderbird-91.11.0/xpcom/idl-parser/xpidl/xpidl.py 2022-07-11 21:55:05.287553042 +0200
@@ -1563,13 +1563,13 @@ class IDLParser(object):
t_ignore = " \t"
def t_multilinecomment(self, t):
- r"/\*(?s).*?\*/"
+ r"/\*(?s:.*?)\*/"
t.lexer.lineno += t.value.count("\n")
if t.value.startswith("/**"):
self._doccomments.append(t.value)
def t_singlelinecomment(self, t):
- r"(?m)//.*?$"
+ r"(?m://.*?$)"
def t_IID(self, t):
return t
@@ -1582,7 +1582,7 @@ class IDLParser(object):
return t
def t_LCDATA(self, t):
- r"(?s)%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?"
+ r"(?s:%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?)"
t.type = "CDATA"
t.value = t.lexer.lexmatch.group("cdata")
t.lexer.lineno += t.value.count("\n")

View File

@ -100,7 +100,7 @@ ExcludeArch: s390x
Summary: Mozilla Thunderbird mail/newsgroup client
Name: thunderbird
Version: 91.11.0
Release: 2%{?dist}
Release: 3%{?dist}
URL: http://www.mozilla.org/projects/thunderbird/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Source0: https://archive.mozilla.org/pub/thunderbird/releases/%{version}%{?pre_version}/source/thunderbird-%{version}%{?pre_version}.source.tar.xz
@ -131,6 +131,10 @@ Patch103: rhbz-1219542-s390-build.patch
# gcc 12 build fix patches
Patch421: gcc12-D139088.patch
Patch422: 0001-GLIBCXX-fix-for-GCC-12.patch
# Python 3.11 "ValueError: invalid mode: 'rU'"; 'U' is deprecated since Python 3 and default, error with Python 3.11
Patch423: python3.11-open-U.patch
# Python 3.11 "Invalid regular expression for rule '...'. global flags not at the start of the expression at position ...
Patch424: python3.11-regex-inline-flags.patch
# PPC fix
Patch304: mozilla-1245783.patch
@ -311,6 +315,8 @@ popd
%patch421 -p1 -b .gcc12-D139088
%patch422 -p1 -b .0001-GLIBCXX-fix-for-GCC-12
%patch423 -p1 -b .python3.11-open-U
%patch424 -p1 -b .python3.11-regex-inline-flags
%patch501 -p1 -b .expat-CVE-2022-25235
%patch502 -p1 -b .expat-CVE-2022-25236
@ -746,6 +752,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#===============================================================================
%changelog
* Mon Jul 11 2022 Eike Rathke <erack@redhat.com> - 91.11.0-3
- Fix f37 FTBFS Python 3.11 API incompatibilities
* Tue Jul 05 2022 Tom Stellard <tstellar@redhat.com> - 91.11.0-2
- Clean up macros that allow building with clang