Skip to content

Commit 96e08a4

Browse files
authored
Initialize warnings module during interpreter startup to process (#6766)
1 parent 6616961 commit 96e08a4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/test/test_warnings/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,6 @@ def test_improper_option(self):
841841
rc, out, err = assert_python_ok("-Wxxx", "-c", "pass")
842842
self.assertIn(b"Invalid -W option ignored: invalid action: 'xxx'", err)
843843

844-
# TODO: RUSTPYTHON
845-
@unittest.expectedFailure
846844
def test_warnings_bootstrap(self):
847845
# Check that the warnings module does get loaded when -W<some option>
848846
# is used (see issue #10372 for an example of silent bootstrap failure).

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> {
219219
);
220220
}
221221

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+
222228
// _PyPathConfig_ComputeSysPath0 - set sys.path[0] after site import
223229
if !vm.state.config.settings.safe_path {
224230
let path0: Option<String> = match &run_mode {

0 commit comments

Comments
 (0)