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 @@ -54,7 +54,7 @@ pub mod frame;
54
54
mod frozen;
55
55
pub mod function;
56
56
pub mod import;
57
- mod iterator;
57
+ pub mod iterator;
58
58
mod py_io;
59
59
pub mod py_serde;
60
60
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 @@ -86,7 +86,7 @@ pub(crate) mod thread {
86
86
} )
87
87
}
88
88
89
- pub fn with_vm < F , R > ( obj : & PyObjectRef , f : F ) -> R
89
+ pub fn with_vm < F , R > ( obj : & PyObjectRef , f : F ) -> Option < R >
90
90
where
91
91
F : Fn ( & VirtualMachine ) -> R ,
92
92
{
@@ -101,14 +101,12 @@ pub(crate) mod thread {
101
101
debug_assert ! ( vm_owns_obj( x) ) ;
102
102
x
103
103
}
104
- Err ( mut others) => others
105
- . find ( |x| vm_owns_obj ( * x) )
106
- . unwrap_or_else ( || panic ! ( "can't get a vm for {:?}; none on stack" , obj) ) ,
104
+ Err ( mut others) => others. find ( |x| vm_owns_obj ( * x) ) ?,
107
105
} ;
108
106
// SAFETY: all references in VM_STACK should be valid, and should not be changed or moved
109
107
// at least until this function returns and the stack unwinds to an enter_vm() call
110
108
let vm = unsafe { intp. as_ref ( ) } ;
111
- f ( vm)
109
+ Some ( f ( vm) )
112
110
} )
113
111
}
114
112
}
You can’t perform that action at this time.
0 commit comments