File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ pub mod frame;
52
52
mod frozen;
53
53
pub mod function;
54
54
pub mod import;
55
- mod iterator;
55
+ pub mod iterator;
56
56
mod py_io;
57
57
pub mod py_serde;
58
58
pub mod pyobject;
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ impl Drop for PyObjectRef {
307
307
// CPython-compatible drop implementation
308
308
let zelf = self . clone ( ) ;
309
309
if let Some ( del_slot) = self . class ( ) . mro_find_map ( |cls| cls. slots . del . load ( ) ) {
310
- crate :: vm:: thread:: with_vm ( & zelf, |vm| {
310
+ let ret = crate :: vm:: thread:: with_vm ( & zelf, |vm| {
311
311
if let Err ( e) = del_slot ( & zelf, vm) {
312
312
// exception in del will be ignored but printed
313
313
print ! ( "Exception ignored in: " , ) ;
@@ -327,6 +327,9 @@ impl Drop for PyObjectRef {
327
327
}
328
328
}
329
329
} ) ;
330
+ if ret. is_none ( ) {
331
+ warn ! ( "couldn't run __del__ method for object" )
332
+ }
330
333
}
331
334
332
335
// __del__ might have resurrected the object at this point, but that's fine,
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ pub(crate) mod thread {
81
81
} )
82
82
}
83
83
84
- pub fn with_vm < F , R > ( obj : & PyObjectRef , f : F ) -> R
84
+ pub fn with_vm < F , R > ( obj : & PyObjectRef , f : F ) -> Option < R >
85
85
where
86
86
F : Fn ( & VirtualMachine ) -> R ,
87
87
{
@@ -96,14 +96,12 @@ pub(crate) mod thread {
96
96
debug_assert ! ( vm_owns_obj( x) ) ;
97
97
x
98
98
}
99
- Err ( mut others) => others
100
- . find ( |x| vm_owns_obj ( * x) )
101
- . unwrap_or_else ( || panic ! ( "can't get a vm for {:?}; none on stack" , obj) ) ,
99
+ Err ( mut others) => others. find ( |x| vm_owns_obj ( * x) ) ?,
102
100
} ;
103
101
// SAFETY: all references in VM_STACK should be valid, and should not be changed or moved
104
102
// at least until this function returns and the stack unwinds to an enter_vm() call
105
103
let vm = unsafe { intp. as_ref ( ) } ;
106
- f ( vm)
104
+ Some ( f ( vm) )
107
105
} )
108
106
}
109
107
}
You can’t perform that action at this time.
0 commit comments