https://github.com/python/cpython/commit/faf4e524356634ac95d9de3f7f115603f7440a9b
commit: faf4e524356634ac95d9de3f7f115603f7440a9b
branch: main
author: stratakis <[email protected]>
committer: encukou <[email protected]>
date: 2026-09-01T08:22:05+02:00
summary:
gh-156703: Set LD_LIBRARY_PATH in SystemTap trace commands (GH-156424)
Prefix commands passed to stap -c with LD_LIBRARY_PATH via env, when
probes reside in libpython. This allows the interpreter to find
libpython when staprun does not preserve the loader path.
files:
M Lib/test/test_dtrace.py
diff --git a/Lib/test/test_dtrace.py b/Lib/test/test_dtrace.py
index 4967a18053057b..126e47a20cb7c6 100644
--- a/Lib/test/test_dtrace.py
+++ b/Lib/test/test_dtrace.py
@@ -229,6 +229,17 @@ def render_script(self, filename):
return script.replace(self.PROBE_PLACEHOLDER, self.python_probe())
+ def generate_trace_command(self, script_file, subcommand=None):
+ probe_binary = get_probe_binary()
+ if subcommand and probe_binary != sys.executable:
+ library_path = os.path.dirname(probe_binary)
+ if existing_path := os.environ.get("LD_LIBRARY_PATH"):
+ library_path = os.pathsep.join((library_path, existing_path))
+ env = shlex.join(["env", f"LD_LIBRARY_PATH={library_path}"])
+ subcommand = f"{env} {subcommand}"
+
+ return super().generate_trace_command(script_file, subcommand)
+
def trace(self, script_file, subcommand=None, *, timeout=None,
check_returncode=False):
with tempfile.NamedTemporaryFile(
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]