diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index a8d39dc55c6..ae9a365e1c9 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -841,8 +841,6 @@ def test_improper_option(self): rc, out, err = assert_python_ok("-Wxxx", "-c", "pass") self.assertIn(b"Invalid -W option ignored: invalid action: 'xxx'", err) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_warnings_bootstrap(self): # Check that the warnings module does get loaded when -W # is used (see issue #10372 for an example of silent bootstrap failure). diff --git a/src/lib.rs b/src/lib.rs index 77c9095ad41..11f6dc01c35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -219,6 +219,12 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> { ); } + // 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 = match &run_mode {