Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
fix macos
  • Loading branch information
youknowone committed Dec 29, 2025
commit 5c5caccfd930f1ecf3b064c6063b2a336672a3a0
19 changes: 17 additions & 2 deletions crates/vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ pub mod module {
#[pyarg(positional)]
args: crate::function::ArgIterable<OsPath>,
#[pyarg(positional)]
env: crate::function::ArgMapping,
env: Option<crate::function::ArgMapping>,
#[pyarg(named, default)]
file_actions: Option<crate::function::ArgIterable<PyTupleRef>>,
#[pyarg(named, default)]
Expand Down Expand Up @@ -1678,7 +1678,22 @@ pub mod module {
.map_err(|_| vm.new_value_error("path should not have nul bytes"))
})
.collect::<Result<_, _>>()?;
let env = envp_from_dict(self.env, vm)?;
let env = if let Some(env_dict) = self.env {
envp_from_dict(env_dict, vm)?
} else {
// env=None means use the current environment
use rustpython_common::os::ffi::OsStringExt;
env::vars_os()
.map(|(k, v)| {
let mut entry = k.into_vec();
entry.push(b'=');
entry.extend(v.into_vec());
CString::new(entry).map_err(|_| {
vm.new_value_error("environment string contains null byte")
})
})
.collect::<PyResult<Vec<_>>>()?
};

let ret = if spawnp {
nix::spawn::posix_spawnp(&path, &file_actions, &attrp, &args, &env)
Expand Down
Loading