add __str__ in PyWeakProxy

file : test_deque.py
  method : test_weakref()

  error occurred because the return value of str() was different
  so add __str__() in weakproxy
Signed-off-by: CHOUMnote <rlawlgh1028@naver.com>
This commit is contained in:
CHOUMnote
2022-05-21 16:34:34 +09:00
parent b289aa57b6
commit 3ccccfcabe

View File

@@ -70,6 +70,16 @@ impl PyWeakProxy {
})?;
obj.get_attr(attr_name, vm)
}
#[pymethod(magic)]
fn str(&self, vm: &VirtualMachine) -> PyResult<PyStrRef> {
match self.weak.upgrade() {
Some(obj) => obj.str(vm),
None => Err(vm.new_exception_msg(
vm.ctx.exceptions.reference_error.clone(),
"weakly-referenced object no longer exists".to_owned(),
)),
}
}
}
impl SetAttr for PyWeakProxy {