> On Mar 3, 2026, at 9:11 AM, George V. Neville-Neil <[email protected]> wrote: > > The branch main has been updated by gnn: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=bc9229035c5f46674cf06b48d66e9f039b3a9875 > > commit bc9229035c5f46674cf06b48d66e9f039b3a9875 > Author: George V. Neville-Neil <[email protected]> > AuthorDate: 2026-03-03 17:10:26 +0000 > Commit: George V. Neville-Neil <[email protected]> > CommitDate: 2026-03-03 17:10:42 +0000 > > Allow programs run under this program to have arguments. > --- > tools/test/hwpmc/pmctest.py | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/tools/test/hwpmc/pmctest.py b/tools/test/hwpmc/pmctest.py > index ba20306f1d68..1c113c256e32 100755 > --- a/tools/test/hwpmc/pmctest.py > +++ b/tools/test/hwpmc/pmctest.py > @@ -27,6 +27,7 @@ import argparse > import tempfile > from pathlib import Path > import os > +import shlex > > def gather_counters(): > """Run program and return output as array of lines.""" > @@ -58,7 +59,9 @@ def main(): > print("Choose one of --count OR --sample.") > sys.exit() > > - program = Path(args.program).name > + # Split program and arguments properly > + program_parts = shlex.split(args.program) > + program = Path(program_parts[0]).name > > if args.count == True: > tmpdir = tempfile.mkdtemp(prefix=program + "-", > suffix="-counting-pmc") > @@ -73,8 +76,7 @@ def main(): > continue > if args.count == True: > with open(tmpdir + "/" + program + "-" + counter + ".txt", 'w') > as file: > - p = subprocess.Popen(["pmcstat", > - "-p", counter, args.program], > + p = subprocess.Popen(["pmcstat", "-p", counter] + > program_parts, > text=True, stderr=file, stdout=file)
Hi George,
The idiom that ruff recommends here is to use the unpacking operator.
For example, instead of doing:
a = []
b = [] + a
They recommend using:
a = []
b = [*a]
More about the rationale for this suggestion is discussed here:
https://docs.astral.sh/ruff/rules/collection-literal-concatenation/ .
-Enji
signature.asc
Description: Message signed with OpenPGP
