MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_once_registry

Function get_once_registry

crates/vm/src/warn.rs:171–182  ·  view source on GitHub ↗

Get the once registry from sys.modules['warnings']._onceregistry, falling back to vm.state.warnings.once_registry.

(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

169/// Get the once registry from sys.modules['warnings']._onceregistry,
170/// falling back to vm.state.warnings.once_registry.
171fn get_once_registry(vm: &VirtualMachine) -> PyResult<PyObjectRef> {
172 if let Some(registry) = get_warnings_attr(vm, identifier!(&vm.ctx, onceregistry), false)? {
173 if !registry.class().is(vm.ctx.types.dict_type) {
174 return Err(vm.new_type_error(format!(
175 "_warnings.onceregistry must be a dict, not '{}'",
176 registry.class().name()
177 )));
178 }
179 return Ok(registry);
180 }
181 Ok(vm.state.warnings.once_registry.clone().into())
182}
183
184fn already_warned(
185 registry: &PyObject,

Callers 1

warn_explicitFunction · 0.85

Calls 5

get_warnings_attrFunction · 0.85
isMethod · 0.80
ErrClass · 0.50
classMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected