Split only at first equal sign more often

Most of the split calls for the '=' character have a maxsplit set to 1
with only a few exceptions. These should be no exceptions to avoid
unintended behavior.
This commit is contained in:
Tobias Stoeckmann authored and Paolo Bonzini committed 2026-03-04 12:54:20 +01:00
1 parent ce8500b705
commit a91712abef
4 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -1940,7 +1940,7 @@ class NinjaBackend(backends.Backend):
from_subproject: bool, proc_macro_dylib_path: T.Optional[str],
deps: T.List[RustDep]) -> None:
raw_edition: T.Optional[str] = mesonlib.first(reversed(args), lambda x: x.startswith('--edition'))
edition: RUST_EDITIONS = '2015' if not raw_edition else raw_edition.split('=')[-1]
edition: RUST_EDITIONS = '2015' if not raw_edition else raw_edition.split('=', 1)[-1]
cfg: T.List[str] = []
arg_itr: T.Iterator[str] = iter(args)
+1 -1
View File
@@ -553,7 +553,7 @@ class PkgConfigDependency(ExternalDependency):
def extract_field(self, la_file: str, fieldname: str) -> T.Optional[str]:
with open(la_file, encoding='utf-8') as f:
for line in f:
arr = line.strip().split('=')
arr = line.strip().split('=', 1)
if arr[0] == fieldname:
return arr[1][1:-1]
return None
+1 -1
View File
@@ -59,7 +59,7 @@ def setup_backend():
be = 'ninja'
for a in sys.argv:
if a.startswith('--backend'):
be = a.split('=')[1]
be = a.split('=', 1)[1]
else:
filtered.append(a)
# Since we invoke the tests via unittest or xtest test runner
@@ -13,10 +13,10 @@ if __name__ == '__main__':
not args[2].startswith('--output'):
print(args[0], '--input=input_file --output=output_file')
sys.exit(1)
with open(args[1].split('=')[1]) as f:
with open(args[1].split('=', 1)[1]) as f:
ifile = f.read()
if ifile != 'This is a text only input file.\n':
print('Malformed input')
sys.exit(1)
with open(args[2].split('=')[1], 'w') as ofile:
with open(args[2].split('=', 1)[1], 'w') as ofile:
ofile.write('This is a binary output file.\n')