Skip to content

Commit c25cada

Browse files
scripts/test.py: venv_run(): fix arg quoting on windows.
1 parent 584616a commit c25cada

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/test.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,10 +1128,14 @@ def venv_run(args, path, recreate=True):
11281128
if recreate or not os.path.isdir(path):
11291129
run(f'{sys.executable} -m venv {path}')
11301130
if platform.system() == 'Windows':
1131-
command = f'{path}\\Scripts\\activate'
1131+
command = f'{path}\\Scripts\\activate && python'
1132+
# shlex not reliable on Windows.
1133+
# Use crude quoting with "...". Seems to work.
1134+
for arg in args:
1135+
assert '"' not in arg
1136+
command += f' "{arg}"'
11321137
else:
1133-
command = f'. {path}/bin/activate'
1134-
command += f' && python {shlex.join(args)}'
1138+
command = f'. {path}/bin/activate && python {shlex.join(args)}'
11351139
e = run(command, check=0)
11361140
return e
11371141

0 commit comments

Comments
 (0)