|
1 | 1 | import dis |
2 | 2 | import os.path |
3 | 3 | import re |
| 4 | +import shlex |
4 | 5 | import signal |
5 | 6 | import subprocess |
6 | 7 | import sys |
@@ -148,7 +149,7 @@ def trace_python(self, script_file, python_file, optimize_python=None): |
148 | 149 | python_flags = [] |
149 | 150 | if optimize_python: |
150 | 151 | python_flags.extend(["-O"] * optimize_python) |
151 | | - subcommand = " ".join([sys.executable] + python_flags + [python_file]) |
| 152 | + subcommand = shlex.join([sys.executable] + python_flags + [python_file]) |
152 | 153 | return self.trace(script_file, subcommand, timeout=60, |
153 | 154 | check_returncode=True) |
154 | 155 |
|
@@ -276,7 +277,7 @@ def run_case(self, name, optimize_python=None): |
276 | 277 |
|
277 | 278 | try: |
278 | 279 | proc = create_process_group( |
279 | | - ["bpftrace", "-e", program, "-c", " ".join(subcommand)], |
| 280 | + ["bpftrace", "-e", program, "-c", shlex.join(subcommand)], |
280 | 281 | stdout=subprocess.PIPE, |
281 | 282 | stderr=subprocess.PIPE, |
282 | 283 | universal_newlines=True, |
@@ -314,7 +315,8 @@ def assert_usable(self): |
314 | 315 | program = f'usdt:{sys.executable}:python:function__entry {{ printf("probe: success\\n"); exit(); }}' |
315 | 316 | try: |
316 | 317 | proc = create_process_group( |
317 | | - ["bpftrace", "-e", program, "-c", f"{sys.executable} -c pass"], |
| 318 | + ["bpftrace", "-e", program, "-c", |
| 319 | + shlex.join([sys.executable, "-c", "pass"])], |
318 | 320 | stdout=subprocess.PIPE, |
319 | 321 | stderr=subprocess.PIPE, |
320 | 322 | universal_newlines=True, |
|
0 commit comments