init warnings before site by youknowone · Pull Request #6771 · RustPython/RustPython
let scope = vm.new_scope_with_main()?;
// Initialize warnings module to process sys.warnoptions // _PyWarnings_Init() if vm.import("warnings", 0).is_err() { warn!("Failed to import warnings module"); }
// Import site first, before setting sys.path[0] // This matches CPython's behavior where site.removeduppaths() runs // before sys.path[0] is set, preventing '' from being converted to cwd
// Initialize warnings module to process sys.warnoptions // _PyWarnings_Init() if vm.import("warnings", 0).is_err() { warn!("Failed to import warnings module"); }
// _PyPathConfig_ComputeSysPath0 - set sys.path[0] after site import if !vm.state.config.settings.safe_path { let path0: Option<String> = match &run_mode {