Skip to content

Commit e8dd582

Browse files
authored
init warnings before site (RustPython#6771)
1 parent f8a78e6 commit e8dd582

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> {
208208

209209
let scope = vm.new_scope_with_main()?;
210210

211+
// Initialize warnings module to process sys.warnoptions
212+
// _PyWarnings_Init()
213+
if vm.import("warnings", 0).is_err() {
214+
warn!("Failed to import warnings module");
215+
}
216+
211217
// Import site first, before setting sys.path[0]
212218
// This matches CPython's behavior where site.removeduppaths() runs
213219
// before sys.path[0] is set, preventing '' from being converted to cwd
@@ -219,12 +225,6 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> {
219225
);
220226
}
221227

222-
// Initialize warnings module to process sys.warnoptions
223-
// _PyWarnings_Init()
224-
if vm.import("warnings", 0).is_err() {
225-
warn!("Failed to import warnings module");
226-
}
227-
228228
// _PyPathConfig_ComputeSysPath0 - set sys.path[0] after site import
229229
if !vm.state.config.settings.safe_path {
230230
let path0: Option<String> = match &run_mode {

0 commit comments

Comments
 (0)