From 8dc0b18894e25522d180fe30971a83a58b14f199 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 20 Jun 2026 00:29:46 +0530 Subject: [PATCH] refactor(cron): copy os.environ before sanitizing for subprocess MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Matches the env= callsite convention at the other sanitized subprocess spawns (cua_backend dict(os.environ), gateway os.environ.copy()). Functionally equivalent — _sanitize_subprocess_env never mutates its input — but avoids handing the live mapping to the helper. Follow-up to salvaged PR #49207. --- cron/scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cron/scheduler.py b/cron/scheduler.py index 3e7d783f663..413b582b125 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -1035,7 +1035,7 @@ def _run_job_script(script_path: str) -> tuple[bool, str]: text=True, timeout=script_timeout, cwd=str(path.parent), - env=_sanitize_subprocess_env(os.environ), + env=_sanitize_subprocess_env(os.environ.copy()), **popen_kwargs, ) stdout = (result.stdout or "").strip()