projects/aports·blob master · refs

133 lines · 6.0 KiB

1Patch-Source: https://www.linuxfromscratch.org/patches/blfs/svn/firefox-140.9.0esr-python_3.14_fixes-1.patch
2From 95b5674ffdbb965611ae74467558544741e4b3cb Mon Sep 17 00:00:00 2001
3From: Antoine Martin <[email protected]>
4Date: Sat, 4 Apr 2026 16:53:25 -0400
5Subject: [PATCH 1/2] python 3.14 fixes
6
7Submitted By: Douglas R. Reno <renodr at linuxfromscratch dot org>
8Date: 2025-11-24
9Initial Package Version: 140.5.0
10Upstream Status: Applied in mainline Firefox
11Origin: Upstream (phabricator D261511, 261512, 262335)
12Description: Fixes building Firefox, Thunderbird, and Spidermonkey
13 with Python 3.14 by adjusting to various API changes.
14 This includes ast.Str being removed, and changing to
15 ast.Constant.
16---
17 python/mach/mach/command_util.py | 2 +-
18 python/mozbuild/mozbuild/frontend/reader.py | 14 +++++++-------
19 .../mozbuild/mozbuild/vendor/rewrite_mozbuild.py | 6 ++----
20 python/mozbuild/mozbuild/vendor/vendor_python.py | 4 ++++
21 .../python/jsonschema/jsonschema/validators.py | 5 ++++-
22 5 files changed, 18 insertions(+), 13 deletions(-)
23
24diff --git a/python/mach/mach/command_util.py b/python/mach/mach/command_util.py
25index 44e13f1..8539bf3 100644
26--- a/python/mach/mach/command_util.py
27+++ b/python/mach/mach/command_util.py
28@@ -292,7 +292,7 @@ class DecoratorVisitor(ast.NodeVisitor):
29 kwarg_dict = {}
30
31 for name, arg in zip(["command", "subcommand"], decorator.args):
32- kwarg_dict[name] = arg.s
33+ kwarg_dict[name] = arg.value
34
35 for keyword in decorator.keywords:
36 if keyword.arg not in relevant_kwargs:
37diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py
38index 9f6292c..89bf999 100644
39--- a/python/mozbuild/mozbuild/frontend/reader.py
40+++ b/python/mozbuild/mozbuild/frontend/reader.py
41@@ -470,7 +470,7 @@ class TemplateFunction:
42 return c(
43 ast.Subscript(
44 value=c(ast.Name(id=self._global_name, ctx=ast.Load())),
45- slice=c(ast.Index(value=c(ast.Str(s=node.id)))),
46+ slice=c(ast.Index(value=c(ast.Constant(value=node.id)))),
47 ctx=node.ctx,
48 )
49 )
50@@ -1039,8 +1039,8 @@ class BuildReader:
51 else:
52 # Others
53 assert isinstance(target.slice, ast.Index)
54- assert isinstance(target.slice.value, ast.Str)
55- key = target.slice.value.s
56+ assert isinstance(target.slice.value, ast.Constant)
57+ key = target.slice.value.value
58 elif isinstance(target, ast.Attribute):
59 assert isinstance(target.attr, str)
60 key = target.attr
61@@ -1051,11 +1051,11 @@ class BuildReader:
62 value = node.value
63 if isinstance(value, ast.List):
64 for v in value.elts:
65- assert isinstance(v, ast.Str)
66- yield v.s
67+ assert isinstance(v, ast.Constant)
68+ yield v.value
69 else:
70- assert isinstance(value, ast.Str)
71- yield value.s
72+ assert isinstance(value, ast.Constant)
73+ yield value.value
74
75 assignments = []
76
77diff --git a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
78index cfcc0f1..de06b58 100644
79--- a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
80+++ b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
81@@ -327,15 +327,13 @@ def assignment_node_to_source_filename_list(code, node):
82 """
83 if isinstance(node.value, ast.List) and "elts" in node.value._fields:
84 for f in node.value.elts:
85- if not isinstance(f, ast.Constant) and not isinstance(f, ast.Str):
86+ if not isinstance(f, ast.Constant):
87 log(
88 "Found non-constant source file name in list: ",
89 ast_get_source_segment(code, f),
90 )
91 return []
92- return [
93- f.value if isinstance(f, ast.Constant) else f.s for f in node.value.elts
94- ]
95+ return [f.value for f in node.value.elts]
96 elif isinstance(node.value, ast.ListComp):
97 # SOURCES += [f for f in foo if blah]
98 log("Could not find the files for " + ast_get_source_segment(code, node.value))
99diff --git a/python/mozbuild/mozbuild/vendor/vendor_python.py b/python/mozbuild/mozbuild/vendor/vendor_python.py
100index 9acee94..2801e1b 100644
101--- a/python/mozbuild/mozbuild/vendor/vendor_python.py
102+++ b/python/mozbuild/mozbuild/vendor/vendor_python.py
103@@ -40,6 +40,10 @@ EXCLUDED_PACKAGES = {
104 # modified 'dummy' version of it so that the dependency checks still succeed, but
105 # if it ever is attempted to be used, it will fail gracefully.
106 "ansicon",
107+ # jsonschema 4.17.3 is incompatible with Python 3.14+,
108+ # but later versions use a dependency with Rust components, which we thus can't vendor.
109+ # For now we apply the minimal patch to jsonschema to make it work again.
110+ "jsonschema",
111 }
112
113
114diff --git a/third_party/python/jsonschema/jsonschema/validators.py b/third_party/python/jsonschema/jsonschema/validators.py
115index 66e803e..88316a8 100644
116--- a/third_party/python/jsonschema/jsonschema/validators.py
117+++ b/third_party/python/jsonschema/jsonschema/validators.py
118@@ -875,8 +875,11 @@ class RefResolver:
119 return None
120 uri, fragment = urldefrag(url)
121 for subschema in subschemas:
122+ id = subschema["$id"]
123+ if not isinstance(id, str):
124+ continue
125 target_uri = self._urljoin_cache(
126- self.resolution_scope, subschema["$id"],
127+ self.resolution_scope, id,
128 )
129 if target_uri.rstrip("/") == uri.rstrip("/"):
130 if fragment:
131--
1322.53.0
133