diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2022-09-14 14:03:10 +0200 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2022-09-14 11:25:11 -0700 |
commit | 49f76d5b0f13009835bdd7b2234f34d99fa2d597 (patch) | |
tree | ae89c2063d369ff1dd262d5606ceaf1982f82068 | |
parent | fdcf9a04fde11f1bbd16fd915393095b6b45ddb4 (diff) | |
download | meta-openembedded-49f76d5b0f13009835bdd7b2234f34d99fa2d597.tar.gz |
mozjs-91: backport a python 3.11 compatibility patch
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r-- | meta-oe/recipes-extended/mozjs/mozjs-91/py-3.11.patch | 211 | ||||
-rw-r--r-- | meta-oe/recipes-extended/mozjs/mozjs-91_91.13.0.bb | 1 |
2 files changed, 212 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/mozjs/mozjs-91/py-3.11.patch b/meta-oe/recipes-extended/mozjs/mozjs-91/py-3.11.patch new file mode 100644 index 000000000..71da8225a --- /dev/null +++ b/meta-oe/recipes-extended/mozjs/mozjs-91/py-3.11.patch | |||
@@ -0,0 +1,211 @@ | |||
1 | |||
2 | # HG changeset patch | ||
3 | # User ahochheiden <ahochheiden@mozilla.com> | ||
4 | # Date 1654151264 0 | ||
5 | # Node ID f54162b2c1f2fe52c6137ab2c3469a1944f58b27 | ||
6 | # Parent 6e7776492240c27732840d65a33dcc440fa1aba0 | ||
7 | Bug 1769631 - Remove 'U' from 'mode' parameters for various 'open' calls to ensure Python3.11 compatibility r=firefox-build-system-reviewers,glandium | ||
8 | |||
9 | The 'U' flag represents "universal newline". It has been deprecated | ||
10 | since Python3.3. Since then "universal newline" is the default when a | ||
11 | file is opened in text mode (not bytes). In Python3.11 using the 'U' | ||
12 | flag throws errors. There should be no harm in removing 'U' from 'open' | ||
13 | everywhere it is used, and doing allows the use of Python3.11. | ||
14 | |||
15 | For more reading see: https://docs.python.org/3.11/whatsnew/3.11.html#changes-in-the-python-api | ||
16 | |||
17 | Differential Revision: https://phabricator.services.mozilla.com/D147721 | ||
18 | |||
19 | Upstream-Status: Backport [https://hg.mozilla.org/mozilla-central/rev/f54162b2c1f2fe52c6137ab2c3469a1944f58b27] | ||
20 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
21 | |||
22 | diff --git a/dom/base/usecounters.py b/dom/base/usecounters.py | ||
23 | --- a/dom/base/usecounters.py | ||
24 | +++ b/dom/base/usecounters.py | ||
25 | @@ -3,17 +3,17 @@ | ||
26 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
27 | |||
28 | import collections | ||
29 | import re | ||
30 | |||
31 | |||
32 | def read_conf(conf_filename): | ||
33 | # Can't read/write from a single StringIO, so make a new one for reading. | ||
34 | - stream = open(conf_filename, "rU") | ||
35 | + stream = open(conf_filename, "r") | ||
36 | |||
37 | def parse_counters(stream): | ||
38 | for line_num, line in enumerate(stream): | ||
39 | line = line.rstrip("\n") | ||
40 | if not line or line.startswith("//"): | ||
41 | # empty line or comment | ||
42 | continue | ||
43 | m = re.match(r"method ([A-Za-z0-9]+)\.([A-Za-z0-9]+)$", line) | ||
44 | diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py | ||
45 | --- a/python/mozbuild/mozbuild/action/process_define_files.py | ||
46 | +++ b/python/mozbuild/mozbuild/action/process_define_files.py | ||
47 | @@ -31,17 +31,17 @@ def process_define_file(output, input): | ||
48 | |||
49 | config = PartialConfigEnvironment(topobjdir) | ||
50 | |||
51 | if mozpath.basedir( | ||
52 | path, [mozpath.join(topsrcdir, "js/src")] | ||
53 | ) and not config.substs.get("JS_STANDALONE"): | ||
54 | config = PartialConfigEnvironment(mozpath.join(topobjdir, "js", "src")) | ||
55 | |||
56 | - with open(path, "rU") as input: | ||
57 | + with open(path, "r") as input: | ||
58 | r = re.compile( | ||
59 | "^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U | ||
60 | ) | ||
61 | for l in input: | ||
62 | m = r.match(l) | ||
63 | if m: | ||
64 | cmd = m.group("cmd") | ||
65 | name = m.group("name") | ||
66 | diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py | ||
67 | --- a/python/mozbuild/mozbuild/backend/base.py | ||
68 | +++ b/python/mozbuild/mozbuild/backend/base.py | ||
69 | @@ -267,17 +267,17 @@ class BuildBackend(LoggingMixin): | ||
70 | If an exception is raised, |mach build| will fail with a | ||
71 | non-zero exit code. | ||
72 | """ | ||
73 | self._write_purgecaches(config) | ||
74 | |||
75 | return status | ||
76 | |||
77 | @contextmanager | ||
78 | - def _write_file(self, path=None, fh=None, readmode="rU"): | ||
79 | + def _write_file(self, path=None, fh=None, readmode="r"): | ||
80 | """Context manager to write a file. | ||
81 | |||
82 | This is a glorified wrapper around FileAvoidWrite with integration to | ||
83 | update the summary data on this instance. | ||
84 | |||
85 | Example usage: | ||
86 | |||
87 | with self._write_file('foo.txt') as fh: | ||
88 | diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py | ||
89 | --- a/python/mozbuild/mozbuild/preprocessor.py | ||
90 | +++ b/python/mozbuild/mozbuild/preprocessor.py | ||
91 | @@ -526,17 +526,17 @@ class Preprocessor: | ||
92 | if not options.output: | ||
93 | raise Preprocessor.Error( | ||
94 | self, "--depend doesn't work with stdout", None | ||
95 | ) | ||
96 | depfile = get_output_file(options.depend) | ||
97 | |||
98 | if args: | ||
99 | for f in args: | ||
100 | - with io.open(f, "rU", encoding="utf-8") as input: | ||
101 | + with io.open(f, "r", encoding="utf-8") as input: | ||
102 | self.processFile(input=input, output=out) | ||
103 | if depfile: | ||
104 | mk = Makefile() | ||
105 | mk.create_rule([six.ensure_text(options.output)]).add_dependencies( | ||
106 | self.includes | ||
107 | ) | ||
108 | mk.dump(depfile) | ||
109 | depfile.close() | ||
110 | @@ -855,17 +855,17 @@ class Preprocessor: | ||
111 | self.checkLineNumbers = False | ||
112 | if isName: | ||
113 | try: | ||
114 | args = _to_text(args) | ||
115 | if filters: | ||
116 | args = self.applyFilters(args) | ||
117 | if not os.path.isabs(args): | ||
118 | args = os.path.join(self.curdir, args) | ||
119 | - args = io.open(args, "rU", encoding="utf-8") | ||
120 | + args = io.open(args, "r", encoding="utf-8") | ||
121 | except Preprocessor.Error: | ||
122 | raise | ||
123 | except Exception: | ||
124 | raise Preprocessor.Error(self, "FILE_NOT_FOUND", _to_text(args)) | ||
125 | self.checkLineNumbers = bool( | ||
126 | re.search("\.(js|jsm|java|webidl)(?:\.in)?$", args.name) | ||
127 | ) | ||
128 | oldFile = self.context["FILE"] | ||
129 | @@ -909,17 +909,17 @@ class Preprocessor: | ||
130 | |||
131 | def do_error(self, args): | ||
132 | raise Preprocessor.Error(self, "Error: ", _to_text(args)) | ||
133 | |||
134 | |||
135 | def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"): | ||
136 | pp = Preprocessor(defines=defines, marker=marker) | ||
137 | for f in includes: | ||
138 | - with io.open(f, "rU", encoding="utf-8") as input: | ||
139 | + with io.open(f, "r", encoding="utf-8") as input: | ||
140 | pp.processFile(input=input, output=output) | ||
141 | return pp.includes | ||
142 | |||
143 | |||
144 | # Keep this module independently executable. | ||
145 | if __name__ == "__main__": | ||
146 | pp = Preprocessor() | ||
147 | pp.handleCommandLine(None, True) | ||
148 | diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py | ||
149 | --- a/python/mozbuild/mozbuild/util.py | ||
150 | +++ b/python/mozbuild/mozbuild/util.py | ||
151 | @@ -231,17 +231,17 @@ class FileAvoidWrite(BytesIO): | ||
152 | enabled by default because it a) doesn't make sense for binary files b) | ||
153 | could add unwanted overhead to calls. | ||
154 | |||
155 | Additionally, there is dry run mode where the file is not actually written | ||
156 | out, but reports whether the file was existing and would have been updated | ||
157 | still occur, as well as diff capture if requested. | ||
158 | """ | ||
159 | |||
160 | - def __init__(self, filename, capture_diff=False, dry_run=False, readmode="rU"): | ||
161 | + def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"): | ||
162 | BytesIO.__init__(self) | ||
163 | self.name = filename | ||
164 | assert type(capture_diff) == bool | ||
165 | assert type(dry_run) == bool | ||
166 | assert "r" in readmode | ||
167 | self._capture_diff = capture_diff | ||
168 | self._write_to_file = not dry_run | ||
169 | self.diff = None | ||
170 | diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py | ||
171 | --- a/python/mozbuild/mozpack/files.py | ||
172 | +++ b/python/mozbuild/mozpack/files.py | ||
173 | @@ -549,17 +549,17 @@ class PreprocessedFile(BaseFile): | ||
174 | self.defines = defines | ||
175 | self.extra_depends = list(extra_depends or []) | ||
176 | self.silence_missing_directive_warnings = silence_missing_directive_warnings | ||
177 | |||
178 | def inputs(self): | ||
179 | pp = Preprocessor(defines=self.defines, marker=self.marker) | ||
180 | pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) | ||
181 | |||
182 | - with _open(self.path, "rU") as input: | ||
183 | + with _open(self.path, "r") as input: | ||
184 | with _open(os.devnull, "w") as output: | ||
185 | pp.processFile(input=input, output=output) | ||
186 | |||
187 | # This always yields at least self.path. | ||
188 | return pp.includes | ||
189 | |||
190 | def copy(self, dest, skip_if_older=True): | ||
191 | """ | ||
192 | @@ -606,17 +606,17 @@ class PreprocessedFile(BaseFile): | ||
193 | return False | ||
194 | |||
195 | deps_out = None | ||
196 | if self.depfile: | ||
197 | deps_out = FileAvoidWrite(self.depfile) | ||
198 | pp = Preprocessor(defines=self.defines, marker=self.marker) | ||
199 | pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) | ||
200 | |||
201 | - with _open(self.path, "rU") as input: | ||
202 | + with _open(self.path, "r") as input: | ||
203 | pp.processFile(input=input, output=dest, depfile=deps_out) | ||
204 | |||
205 | dest.close() | ||
206 | if self.depfile: | ||
207 | deps_out.close() | ||
208 | |||
209 | return True | ||
210 | |||
211 | |||
diff --git a/meta-oe/recipes-extended/mozjs/mozjs-91_91.13.0.bb b/meta-oe/recipes-extended/mozjs/mozjs-91_91.13.0.bb index c3ee75086..4c1aa3447 100644 --- a/meta-oe/recipes-extended/mozjs/mozjs-91_91.13.0.bb +++ b/meta-oe/recipes-extended/mozjs/mozjs-91_91.13.0.bb | |||
@@ -15,6 +15,7 @@ SRC_URI = "https://archive.mozilla.org/pub/firefox/releases/${PV}esr/source/fire | |||
15 | file://0006-Fix-build-on-powerpc.patch \ | 15 | file://0006-Fix-build-on-powerpc.patch \ |
16 | file://0001-util.configure-fix-one-occasionally-reproduced-confi.patch \ | 16 | file://0001-util.configure-fix-one-occasionally-reproduced-confi.patch \ |
17 | file://0001-rewrite-cargo-host-linker-in-python3.patch \ | 17 | file://0001-rewrite-cargo-host-linker-in-python3.patch \ |
18 | file://py-3.11.patch \ | ||
18 | " | 19 | " |
19 | SRC_URI[sha256sum] = "53be2bcde0b5ee3ec106bd8ba06b8ae95e7d489c484e881dfbe5360e4c920762" | 20 | SRC_URI[sha256sum] = "53be2bcde0b5ee3ec106bd8ba06b8ae95e7d489c484e881dfbe5360e4c920762" |
20 | 21 | ||