Skip to content

Commit c017707

Browse files
Revert "Bug 2068111 - Fix ruff UP031 and PLW2901 warnings in python/mozbuild/mozbuild/action r=firefox-build-system-reviewers,sergesanspaille" for causing build bustages at libmozsqlite3.so.symbols.
This reverts commit 1360793.
1 parent cf73335 commit c017707

12 files changed

Lines changed: 85 additions & 62 deletions

‎python/mozbuild/mozbuild/action/fat_aar.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ def fat_aar(
7777
# Collect multi-architecture inputs to the fat AAR.
7878
copier = FileCopier()
7979

80-
for arch, zip_path_opt in zip_paths.items():
81-
zip_path = zip_path_opt or _download_zip(distdir, arch)
80+
for arch, zip_path in zip_paths.items():
81+
if not zip_path:
82+
zip_path = _download_zip(distdir, arch)
8283
if verbose:
8384
print(f"Processing '{zip_path}' for architecture {arch}")
8485
# Map old non-architecture-specific path to new architecture-specific path.

‎python/mozbuild/mozbuild/action/file_generate_wrapper.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def make_absolute(base_path, p):
3232
except Exception:
3333
relative = os.path.relpath(__file__, topsrcdir)
3434
print(
35-
f"{relative}:action caught exception. params={json.dumps([script, target_dir] + args, indent=2)}\n"
35+
"%s:action caught exception. params=%s\n"
36+
% (relative, json.dumps([script, target_dir] + args, indent=2))
3637
)
3738
raise

‎python/mozbuild/mozbuild/action/generate_symbols_file.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def generate_symbols_file(output, *args):
6969
# is, in fact, part of the symbol name as far as the symbols variable
7070
# is concerned.
7171
assert ext == ".def"
72-
output.write(f"LIBRARY {libname}\nEXPORTS\n " + "\n ".join(symbols) + "\n")
72+
output.write("LIBRARY %s\nEXPORTS\n %s\n" % (libname, "\n ".join(symbols)))
7373
elif (
7474
buildconfig.substs.get("GCC_USE_GNU_LD")
7575
or buildconfig.substs["OS_TARGET"] == "SunOS"
@@ -85,13 +85,11 @@ def generate_symbols_file(output, *args):
8585
# *;
8686
# };
8787
output.write(
88-
f"{libname} {{\nglobal:\n "
89-
+ ";\n ".join(symbols)
90-
+ ";\nlocal:\n *;\n}};"
88+
"%s {\nglobal:\n %s;\nlocal:\n *;\n};" % (libname, ";\n ".join(symbols))
9189
)
9290
elif buildconfig.substs["OS_TARGET"] == "Darwin":
9391
# A list of symbols is generated for Apple ld that simply lists all
9492
# symbols, with an underscore prefix.
95-
output.write("".join(f"_{s}\n" for s in symbols))
93+
output.write("".join("_%s\n" % s for s in symbols))
9694

9795
return set(pp.includes)

‎python/mozbuild/mozbuild/action/langpack_manifest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def _extract_numeric_part(part):
391391

392392
buildid = os.environ.get("MOZ_BUILD_DATE")
393393
if buildid and len(buildid) != 14:
394-
print(f"Ignoring invalid MOZ_BUILD_DATE: {buildid}", file=sys.stderr)
394+
print("Ignoring invalid MOZ_BUILD_DATE: %s" % buildid, file=sys.stderr)
395395
buildid = None
396396

397397
if buildid:

‎python/mozbuild/mozbuild/action/node.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def execute_node_cmd(node_cmd_list):
7070
# XXX Starting with an empty list means that node scripts can
7171
# (intentionally or inadvertently) remove deps. Do we want this?
7272
deps = []
73-
for raw_line in stdout.splitlines():
74-
line = raw_line.decode()
73+
for line in stdout.splitlines():
74+
line = line.decode()
7575
if "dep:" in line:
7676
deps.append(line.replace("dep:", ""))
7777
else:
@@ -86,9 +86,10 @@ def execute_node_cmd(node_cmd_list):
8686
# disambiguate this from real "Permission denied" errors so that we
8787
# can log such problems more clearly?
8888
print(
89-
f"""Failed with {err}. Be sure to check that your mozconfig doesn't
89+
"""Failed with %s. Be sure to check that your mozconfig doesn't
9090
have --disable-nodejs in it. If it does, try removing that line and
91-
building again.""",
91+
building again."""
92+
% str(err),
9293
file=sys.stderr,
9394
)
9495
sys.exit(1)

‎python/mozbuild/mozbuild/action/package_generated_sources.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def is_valid_entry(entry):
2828
entry_abspath = mozpath.abspath(entry[1])
2929
if not entry_abspath.startswith(objdir_abspath):
3030
print(
31-
f"Warning: omitting generated source [{entry_abspath}] from archive",
31+
"Warning: omitting generated source [%s] from archive" % entry_abspath,
3232
file=sys.stderr,
3333
)
3434
return False
@@ -40,7 +40,7 @@ def is_valid_entry(entry):
4040
and not os.path.exists(entry_abspath)
4141
):
4242
print(
43-
f"Warning: omitting non-existing file [{entry_abspath}] from archive",
43+
"Warning: omitting non-existing file [%s] from archive" % entry_abspath,
4444
file=sys.stderr,
4545
)
4646
return False

‎python/mozbuild/mozbuild/action/process_define_files.py‎

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def process_define_file(output, input):
4141
r = re.compile(
4242
r"^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?", re.U
4343
)
44-
for raw_line in input_file:
45-
line = raw_line
46-
if m := r.match(line):
44+
for l in input_file:
45+
m = r.match(l)
46+
if m:
4747
cmd = m.group("cmd")
4848
name = m.group("name")
4949
value = m.group("value")
@@ -71,35 +71,28 @@ def define_for_name(name, val):
7171
for name, val in config.defines["ALLDEFINES"].items()
7272
)
7373
)
74-
line = (
75-
line[: m.start("cmd") - 1] + defines + line[m.end("name") :]
76-
)
74+
l = l[: m.start("cmd") - 1] + defines + l[m.end("name") :]
7775
elif cmd == "define":
7876
if value and name in config.defines:
79-
line = (
80-
line[: m.start("value")]
77+
l = (
78+
l[: m.start("value")]
8179
+ str(config.defines[name])
82-
+ line[m.end("value") :]
80+
+ l[m.end("value") :]
8381
)
8482
elif cmd == "undef":
8583
if name in config.defines:
86-
line = (
87-
line[: m.start("cmd")]
84+
l = (
85+
l[: m.start("cmd")]
8886
+ "define"
89-
+ line[m.end("cmd") : m.end("name")]
87+
+ l[m.end("cmd") : m.end("name")]
9088
+ " "
9189
+ str(config.defines[name])
92-
+ line[m.end("name") :]
90+
+ l[m.end("name") :]
9391
)
9492
else:
95-
line = (
96-
"/* "
97-
+ line[: m.end("name")]
98-
+ " */"
99-
+ line[m.end("name") :]
100-
)
93+
l = "/* " + l[: m.end("name")] + " */" + l[m.end("name") :]
10194

102-
output.write(line)
95+
output.write(l)
10396

10497
deps = {path}
10598
deps.update(config.get_dependencies())

‎python/mozbuild/mozbuild/action/symbols_archive.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def make_archive(archive_name, base, exclude, include):
2020
def fill_archive(add_file):
2121
for pat in include:
2222
for p, f in finder.find(pat):
23-
print(f' Adding to "{archive_basename}":\n\t"{p}"')
23+
print(' Adding to "%s":\n\t"%s"' % (archive_basename, p))
2424
add_file(p, f)
2525

2626
with open(archive_name, "wb") as fh:

‎python/mozbuild/mozbuild/action/test_archive.py‎

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,16 @@
192192
"source": buildconfig.topobjdir,
193193
"base": "dist/bin",
194194
"patterns": [
195-
f"{f}{buildconfig.substs['BIN_SUFFIX']}" for f in TEST_HARNESS_BINS
195+
"%s%s" % (f, buildconfig.substs["BIN_SUFFIX"])
196+
for f in TEST_HARNESS_BINS
196197
]
197198
+ [
198-
f"{buildconfig.substs['DLL_PREFIX']}{f}{buildconfig.substs['DLL_SUFFIX']}"
199+
"%s%s%s"
200+
% (
201+
buildconfig.substs["DLL_PREFIX"],
202+
f,
203+
buildconfig.substs["DLL_SUFFIX"],
204+
)
199205
for f in TEST_HARNESS_DLLS
200206
],
201207
"dest": "bin",
@@ -630,7 +636,7 @@
630636
{
631637
"source": buildconfig.topobjdir,
632638
"base": "dist/bin",
633-
"pattern": f"http3server{buildconfig.substs['BIN_SUFFIX']}",
639+
"pattern": "http3server%s" % buildconfig.substs["BIN_SUFFIX"],
634640
"dest": "xpcshell/http3server",
635641
},
636642
{
@@ -702,10 +708,16 @@
702708
"source": buildconfig.topobjdir,
703709
"base": "dist/bin",
704710
"patterns": [
705-
f"{f}{buildconfig.substs['BIN_SUFFIX']}" for f in TEST_HARNESS_BINS
711+
"%s%s" % (f, buildconfig.substs["BIN_SUFFIX"])
712+
for f in TEST_HARNESS_BINS
706713
]
707714
+ [
708-
f"{buildconfig.substs['DLL_PREFIX']}{f}{buildconfig.substs['DLL_SUFFIX']}"
715+
"%s%s%s"
716+
% (
717+
buildconfig.substs["DLL_PREFIX"],
718+
f,
719+
buildconfig.substs["DLL_SUFFIX"],
720+
)
709721
for f in TRAIN_HOP_DLLS
710722
],
711723
"dest": "bin",
@@ -770,8 +782,8 @@
770782
itertools.chain(*(e.get("ignore", []) for e in ARCHIVE_FILES["common"]))
771783
)
772784

773-
if not any(p.startswith(f"{k}/") for p in ignores):
774-
raise Exception(f'"common" ignore list probably should contain {k}')
785+
if not any(p.startswith("%s/" % k) for p in ignores):
786+
raise Exception('"common" ignore list probably should contain %s' % k)
775787

776788

777789
def find_generated_harness_files():
@@ -848,8 +860,9 @@ def find_files(archive):
848860
finder = FileFinder(os.path.join(source, base), **common_kwargs)
849861

850862
for pattern in patterns:
851-
for raw_p, f in finder.find(pattern):
852-
p = mozpath.join(dest, raw_p) if dest else raw_p
863+
for p, f in finder.find(pattern):
864+
if dest:
865+
p = mozpath.join(dest, p)
853866
yield p, f
854867

855868

@@ -860,22 +873,22 @@ def find_manifest_dirs(topsrcdir, manifests):
860873
"""
861874
dirs = set()
862875

863-
for manifest_path in manifests:
864-
abs_manifest_path = os.path.join(topsrcdir, manifest_path)
876+
for p in manifests:
877+
p = os.path.join(topsrcdir, p)
865878

866-
if abs_manifest_path.endswith(".ini") or abs_manifest_path.endswith(".toml"):
879+
if p.endswith(".ini") or p.endswith(".toml"):
867880
test_manifest = TestManifest()
868-
test_manifest.read(abs_manifest_path)
881+
test_manifest.read(p)
869882
dirs |= set([os.path.dirname(m) for m in test_manifest.manifests()])
870883

871-
elif abs_manifest_path.endswith(".list"):
884+
elif p.endswith(".list"):
872885
m = ReftestManifest()
873-
m.load(abs_manifest_path)
886+
m.load(p)
874887
dirs |= m.dirs
875888

876889
else:
877890
raise Exception(
878-
f'"{os.path.splitext(abs_manifest_path)[1]}" is not a supported manifest format.'
891+
f'"{os.path.splitext(p)[1]}" is not a supported manifest format.'
879892
)
880893

881894
dirs = {mozpath.normpath(d[len(topsrcdir) :]).lstrip("/") for d in dirs}
@@ -933,13 +946,14 @@ def main(argv):
933946
)
934947
file_count += 1
935948
else:
936-
raise Exception(f"unhandled file extension: {out_file}")
949+
raise Exception("unhandled file extension: %s" % out_file)
937950

938951
duration = time.monotonic() - t_start
939952
zip_size = os.path.getsize(args.outputfile)
940953
basename = os.path.basename(args.outputfile)
941954
print(
942-
f"Wrote {file_count} files in {zip_size} bytes to {basename} in {duration:.2f}s"
955+
"Wrote %d files in %d bytes to %s in %.2fs"
956+
% (file_count, zip_size, basename, duration)
943957
)
944958

945959

‎python/mozbuild/mozbuild/action/wrap_rustc.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def parse_file(f):
3636
args += ["-L", val]
3737
else:
3838
raise Exception(
39-
f'Unknown flag passed through "cargo:rustc-flags": "{flag}"'
39+
"Unknown flag passed through "
40+
'"cargo:rustc-flags": "%s"' % flag
4041
)
4142
elif key == "rustc-link-lib" and f == crate_output:
4243
args += ["-l", value]

0 commit comments

Comments
 (0)