From c8e268a63882a9cdeb48d5e2f0e030e14a50e57d Mon Sep 17 00:00:00 2001
From: Zach van Rijn <me@zv.io>
Date: Mon, 28 Nov 2022 11:29:39 -0600
Subject: user/thunderbird: add patches for python 3.11. fixes #900.

---
 user/thunderbird/APKBUILD                          |   6 +-
 user/thunderbird/python3.11-open-U.patch           | 102 +++++++++++++++++++++
 .../python3.11-regex-inline-flags.patch            |  27 ++++++
 3 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 user/thunderbird/python3.11-open-U.patch
 create mode 100644 user/thunderbird/python3.11-regex-inline-flags.patch

(limited to 'user')

diff --git a/user/thunderbird/APKBUILD b/user/thunderbird/APKBUILD
index 6791ecdcd..99d89282b 100644
--- a/user/thunderbird/APKBUILD
+++ b/user/thunderbird/APKBUILD
@@ -1,7 +1,7 @@
 # Maintainer: A. Wilcox <awilfox@adelielinux.org>
 pkgname=thunderbird
 pkgver=91.13.0
-pkgrel=0
+pkgrel=1
 pkgdesc="Email client from Mozilla"
 url="https://www.thunderbird.net/"
 arch="all"
@@ -34,6 +34,8 @@ source="https://archive.mozilla.org/pub/thunderbird/releases/$pkgver/source/thun
 	mozilla-build-arm.patch
 	newer-cbindgen.patch
 	ppc32-fix.patch
+	python3.11-open-U.patch
+	python3.11-regex-inline-flags.patch
 	rust-32bit.patch
 	shut-up-warning.patch
 	skia-unified.patch
@@ -147,6 +149,8 @@ c0b2bf43206c2a5154e560ef30189a1062ae856861b39f52ce69002390ff9972d43e387bfd2bf8d2
 e61664bc93eadce5016a06a4d0684b34a05074f1815e88ef2613380d7b369c6fd305fb34f83b5eb18b9e3138273ea8ddcfdcb1084fdcaa922a1e5b30146a3b18  mozilla-build-arm.patch
 eb158bf2e4b9d513ae36f3c977a3b110ea8c4801c3c94841bc3ad4cdca3bdfc96d4a662e5a2e662fe7a01b0f1af097280097b16f5d0e83d29b4a7e6cbb8c7396  newer-cbindgen.patch
 06a3f4ee6d3726adf3460952fcbaaf24bb15ef8d15b3357fdd1766c7a62b00bd53a1e943b5df7f4e1a69f4fae0d44b64fae1e027d7812499c77894975969ea10  ppc32-fix.patch
+07c311921e50fdb86c587000418306292548117f32a69b78db9d8ebd3a1b08196774a3d284b7e2898a2f1fbb9987b2367092f33957824514fd3d7c7b618a83e2  python3.11-open-U.patch
+c9c5610b99e73a1eedd3510e73921cba84f8c6d0c58fc7fe5b4a7ec261bd5fe530560856fba46d6b37f84c6e467d5b43946968dc8230b5491bba976b0b5ae33c  python3.11-regex-inline-flags.patch
 153f955169e1489d49867be90f68e8a4722cad8edb3a9d1ddb6161e34399e1b4e9e82dc8d72aaba1d5f585bca7c4852433e8ecb068be1583df7155c7cce0223b  rust-32bit.patch
 39ddb15d1453a8412275c36fc8db3befc69dffd4a362e932d280fb7fd1190db595a2af9b468ee49e0714f5e9df6e48eb5794122a64fa9f30d689de8693acbb15  shut-up-warning.patch
 961fa1c856e97e4d08da4682f520ecf23075571a532a781c5e14dbec4915130b02a8199caf6602013ea904d347c4f06d086b0fe84a3850dd6910d351232da599  skia-unified.patch
diff --git a/user/thunderbird/python3.11-open-U.patch b/user/thunderbird/python3.11-open-U.patch
new file mode 100644
index 000000000..8cbab9c0a
--- /dev/null
+++ b/user/thunderbird/python3.11-open-U.patch
@@ -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()
diff --git a/user/thunderbird/python3.11-regex-inline-flags.patch b/user/thunderbird/python3.11-regex-inline-flags.patch
new file mode 100644
index 000000000..39481ec01
--- /dev/null
+++ b/user/thunderbird/python3.11-regex-inline-flags.patch
@@ -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")
-- 
cgit v1.2.3-70-g09d2