Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sentry_sdk/integrations/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ def sentry_patched_popen_init(self, *a, **kw):
):
if env is None:
env = _init_argument(
a, kw, "env", 10, lambda x: dict(x or os.environ)
a,
kw,
"env",
10,
lambda x: dict(x if x is not None else os.environ),
)
env["SUBPROCESS_" + k.upper().replace("-", "_")] = v

Expand Down
13 changes: 13 additions & 0 deletions tests/integrations/stdlib/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ def test_subprocess_basic(
assert sys.executable + " -c" in subprocess_init_span["description"]


def test_subprocess_empty_env(sentry_init, monkeypatch):
monkeypatch.setenv("TEST_MARKER", "should_not_be_seen")
sentry_init(integrations=[StdlibIntegration()], traces_sample_rate=1.0)
with start_transaction(name="foo"):
args = [
sys.executable,
"-c",
"import os; print(os.environ.get('TEST_MARKER', None))",
]
output = subprocess.check_output(args, env={}, universal_newlines=True)
assert "should_not_be_seen" not in output


def test_subprocess_invalid_args(sentry_init):
sentry_init(integrations=[StdlibIntegration()])

Expand Down