https://github.com/python/cpython/commit/2befd17167f544158398b91aacab2c42b079b611 commit: 2befd17167f544158398b91aacab2c42b079b611 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: encukou <[email protected]> date: 2026-10-12T14:07:58+02:00 summary:
[3.15] gh-156703: Set LD_LIBRARY_PATH in SystemTap trace commands (GH-156424) (GH-156755) 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. (cherry picked from commit faf4e524356634ac95d9de3f7f115603f7440a9b) Co-authored-by: stratakis <[email protected]> files: M Lib/test/test_dtrace.py diff --git a/Lib/test/test_dtrace.py b/Lib/test/test_dtrace.py index 1700e522ec64e0..d398c0789d24a1 100644 --- a/Lib/test/test_dtrace.py +++ b/Lib/test/test_dtrace.py @@ -243,6 +243,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]
