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

Method dealloc_warn

crates/vm/src/stdlib/_io.rs:5955–5970  ·  view source on GitHub ↗

Issue ResourceWarning if fd is still open and closefd is true.

(zelf: &Py<Self>, source: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

5953 impl FileIO {
5954 /// Issue ResourceWarning if fd is still open and closefd is true.
5955 fn dealloc_warn(zelf: &Py<Self>, source: PyObjectRef, vm: &VirtualMachine) {
5956 if zelf.fd.load() >= 0 && zelf.closefd.load() {
5957 let repr = source
5958 .repr(vm)
5959 .map(|s| s.as_wtf8().to_owned())
5960 .unwrap_or_else(|_| Wtf8Buf::from("<file>"));
5961 if let Err(e) = crate::stdlib::_warnings::warn(
5962 vm.ctx.exceptions.resource_warning,
5963 format!("unclosed file {repr}"),
5964 1,
5965 vm,
5966 ) {
5967 vm.run_unraisable(e, None, zelf.as_object().to_owned());
5968 }
5969 }
5970 }
5971 }
5972
5973 impl Destructor for FileIO {

Callers

nothing calls this directly

Calls 8

run_unraisableMethod · 0.80
warnFunction · 0.70
loadMethod · 0.45
mapMethod · 0.45
reprMethod · 0.45
to_ownedMethod · 0.45
as_wtf8Method · 0.45
as_objectMethod · 0.45

Tested by

no test coverage detected