Fix slot call deadlock

This commit is contained in:
Jeong Yunwon
2022-06-16 20:53:59 +09:00
parent 60598b699e
commit 770f166edf
7 changed files with 23 additions and 21 deletions

View File

@@ -84,14 +84,14 @@ where
T: TryFromObject,
{
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
let iterfn;
{
let iterfn = {
let cls = obj.class();
iterfn = cls.mro_find_map(|x| x.slots.iter.load());
let iterfn = cls.mro_find_map(|x| x.slots.iter.load());
if iterfn.is_none() && !cls.has_attr(identifier!(vm, __getitem__)) {
return Err(vm.new_type_error(format!("'{}' object is not iterable", cls.name())));
}
}
iterfn
};
Ok(Self {
iterable: obj,
iterfn,