Get the once registry from sys.modules['warnings']._onceregistry, falling back to vm.state.warnings.once_registry.
(vm: &VirtualMachine)
| 169 | /// Get the once registry from sys.modules['warnings']._onceregistry, |
| 170 | /// falling back to vm.state.warnings.once_registry. |
| 171 | fn 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 | |
| 184 | fn already_warned( |
| 185 | registry: &PyObject, |
no test coverage detected