Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ def check_iter_pickle(self, it, seq, proto):
it = pickle.loads(d)
self.assertEqual(list(it), seq[1:])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_import(self):
__import__('sys')
__import__('time')
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,8 +1403,6 @@ def test_absolute_circular_submodule(self):
str(cm.exception),
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_unwritable_module(self):
self.addCleanup(unload, "test.test_import.data.unwritable")
self.addCleanup(unload, "test.test_import.data.unwritable.x")
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_importlib/import_/test___package__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def test_using___name__(self):
'__path__': []})
self.assertEqual(module.__name__, 'pkg')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_warn_when_using___name__(self):
with self.assertWarns(ImportWarning):
self.import_module({'__name__': 'pkg.fake', '__path__': []})
Expand All @@ -75,8 +73,6 @@ def test_spec_fallback(self):
module = self.import_module({'__spec__': FakeSpec('pkg.fake')})
self.assertEqual(module.__name__, 'pkg')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_warn_when_package_and_spec_disagree(self):
# Raise a DeprecationWarning if __package__ != __spec__.parent.
with self.assertWarns(DeprecationWarning):
Expand Down
8 changes: 0 additions & 8 deletions Lib/test/test_importlib/import_/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ def test_gh86298_loader_is_none_and_spec_loader_is_none(self):
ValueError,
_bootstrap_external._bless_my_loader, bar.__dict__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_gh86298_no_spec(self):
bar = ModuleType('bar')
bar.__loader__ = object()
Expand All @@ -137,8 +135,6 @@ def test_gh86298_no_spec(self):
DeprecationWarning,
_bootstrap_external._bless_my_loader, bar.__dict__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_gh86298_spec_is_none(self):
bar = ModuleType('bar')
bar.__loader__ = object()
Expand All @@ -148,8 +144,6 @@ def test_gh86298_spec_is_none(self):
DeprecationWarning,
_bootstrap_external._bless_my_loader, bar.__dict__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_gh86298_no_spec_loader(self):
bar = ModuleType('bar')
bar.__loader__ = object()
Expand All @@ -159,8 +153,6 @@ def test_gh86298_no_spec_loader(self):
DeprecationWarning,
_bootstrap_external._bless_my_loader, bar.__dict__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_gh86298_loader_and_spec_loader_disagree(self):
bar = ModuleType('bar')
bar.__loader__ = object()
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_importlib/import_/test_meta_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def test_continuing(self):
with util.import_state(meta_path=[first, second]):
self.assertIs(self.__import__(mod_name), second.modules[mod_name])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_empty(self):
# Raise an ImportWarning if sys.meta_path is empty.
module_name = 'nothing'
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_importlib/import_/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ def test_path_hooks(self):
self.assertIn(path, sys.path_importer_cache)
self.assertIs(sys.path_importer_cache[path], importer)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_empty_path_hooks(self):
# Test that if sys.path_hooks is empty a warning is raised,
# sys.path_importer_cache gets None set, and PathFinder returns None.
Expand Down
17 changes: 14 additions & 3 deletions crates/vm/src/warn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ fn get_warnings_attr(
Err(_) => return Ok(None),
}
} else {
// TODO: finalizing support
return Ok(None);
// Check sys.modules for already-imported warnings module
// This is what CPython does with PyImport_GetModule
match vm.sys_module.get_attr(identifier!(vm, modules), vm) {
Ok(modules) => match modules.get_item(vm.ctx.intern_str("warnings"), vm) {
Ok(module) => module,
Err(_) => return Ok(None),
},
Err(_) => return Ok(None),
}
};
Ok(Some(module.get_attr(attr_name, vm)?))
}
Expand Down Expand Up @@ -320,9 +327,13 @@ fn call_show_warning(
return Err(vm.new_type_error("unable to get warnings.WarningMessage"));
};

// Create a Warning instance by calling category(message)
// This is what warnings module does
let warning_instance = category.as_object().call((message,), vm)?;

let msg = warnmsg_cls.call(
vec![
message.into(),
warning_instance,
category.into(),
filename.into(),
vm.new_pyobj(lineno),
Expand Down
Loading