FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-98894: Quote test_dtrace tracer subcommands by stratakis · Pull Request #152901 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 7 additions & 5 deletions Lib/test/test_dtrace.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dis
import os.path
import re
import shlex
import signal
import subprocess
import sys
Expand Down Expand Up @@ -92,7 +93,7 @@ def run_readelf(cmd):

if proc.returncode:
raise AssertionError(
f"Command {' '.join(cmd)!r} failed "
f"Command {shlex.join(cmd)!r} failed "
Comment thread
stratakis marked this conversation as resolved.
f"with exit code {proc.returncode}: "
f"stdout={stdout!r} stderr={stderr!r}"
)
Expand Down Expand Up @@ -139,7 +140,7 @@ def trace(self, script_file, subcommand=None, *, timeout=None,
raise
if check_returncode and proc.returncode:
raise AssertionError(
f"Command {' '.join(command)!r} failed "
f"Command {shlex.join(command)!r} failed "
f"with exit code {proc.returncode}: output={stdout!r}"
)
return stdout
Expand All @@ -148,7 +149,7 @@ def trace_python(self, script_file, python_file, optimize_python=None):
python_flags = []
if optimize_python:
python_flags.extend(["-O"] * optimize_python)
subcommand = " ".join([sys.executable] + python_flags + [python_file])
subcommand = shlex.join([sys.executable] + python_flags + [python_file])
return self.trace(script_file, subcommand, timeout=60,
check_returncode=True)

Expand Down Expand Up @@ -276,7 +277,7 @@ def run_case(self, name, optimize_python=None):

try:
proc = create_process_group(
["bpftrace", "-e", program, "-c", " ".join(subcommand)],
["bpftrace", "-e", program, "-c", shlex.join(subcommand)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
Expand Down Expand Up @@ -314,7 +315,8 @@ def assert_usable(self):
program = f'usdt:{sys.executable}:python:function__entry {{ printf("probe: success\\n"); exit(); }}'
try:
proc = create_process_group(
["bpftrace", "-e", program, "-c", f"{sys.executable} -c pass"],
["bpftrace", "-e", program, "-c",
shlex.join([sys.executable, "-c", "pass"])],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
Expand Down
Loading

Back | FazBrowse Home | New Git URL