Skip to content

Commit 0a22be6

Browse files
authored
Fix building with recent python versions. (#674)
Signed-off-by: Josh Matthews <[email protected]>
1 parent 256cc57 commit 0a22be6

File tree

4 files changed

+72
-12
lines changed

4 files changed

+72
-12
lines changed

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.140.5-5"
5+
version = "0.140.5-6"
66
authors = ["Mozilla", "The Servo Project Developers"]
77
links = "mozjs"
88
license.workspace = true
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py
2+
index 9f6292cb909de..89bf9995c1768 100644
3+
--- a/python/mozbuild/mozbuild/frontend/reader.py
4+
+++ b/python/mozbuild/mozbuild/frontend/reader.py
5+
@@ -470,7 +470,7 @@ def c(new_node):
6+
return c(
7+
ast.Subscript(
8+
value=c(ast.Name(id=self._global_name, ctx=ast.Load())),
9+
- slice=c(ast.Index(value=c(ast.Str(s=node.id)))),
10+
+ slice=c(ast.Index(value=c(ast.Constant(value=node.id)))),
11+
ctx=node.ctx,
12+
)
13+
)
14+
@@ -1039,8 +1039,8 @@ def assigned_variable(node):
15+
else:
16+
# Others
17+
assert isinstance(target.slice, ast.Index)
18+
- assert isinstance(target.slice.value, ast.Str)
19+
- key = target.slice.value.s
20+
+ assert isinstance(target.slice.value, ast.Constant)
21+
+ key = target.slice.value.value
22+
elif isinstance(target, ast.Attribute):
23+
assert isinstance(target.attr, str)
24+
key = target.attr
25+
@@ -1051,11 +1051,11 @@ def assigned_values(node):
26+
value = node.value
27+
if isinstance(value, ast.List):
28+
for v in value.elts:
29+
- assert isinstance(v, ast.Str)
30+
- yield v.s
31+
+ assert isinstance(v, ast.Constant)
32+
+ yield v.value
33+
else:
34+
- assert isinstance(value, ast.Str)
35+
- yield value.s
36+
+ assert isinstance(value, ast.Constant)
37+
+ yield value.value
38+
39+
assignments = []
40+
41+
diff --git a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
42+
index cfcc0f18b9a9a..de06b58819b6a 100644
43+
--- a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
44+
+++ b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
45+
@@ -327,15 +327,13 @@ def assignment_node_to_source_filename_list(code, node):
46+
"""
47+
if isinstance(node.value, ast.List) and "elts" in node.value._fields:
48+
for f in node.value.elts:
49+
- if not isinstance(f, ast.Constant) and not isinstance(f, ast.Str):
50+
+ if not isinstance(f, ast.Constant):
51+
log(
52+
"Found non-constant source file name in list: ",
53+
ast_get_source_segment(code, f),
54+
)
55+
return []
56+
- return [
57+
- f.value if isinstance(f, ast.Constant) else f.s for f in node.value.elts
58+
- ]
59+
+ return [f.value for f in node.value.elts]
60+
elif isinstance(node.value, ast.ListComp):
61+
# SOURCES += [f for f in foo if blah]
62+
log("Could not find the files for " + ast_get_source_segment(code, node.value))

mozjs-sys/mozjs/python/mozbuild/mozbuild/frontend/reader.py

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)