File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments