Skip to content

Commit 3ccccfc

Browse files
committed
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>
1 parent b289aa5 commit 3ccccfc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

vm/src/builtins/weakproxy.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ impl PyWeakProxy {
7070
})?;
7171
obj.get_attr(attr_name, vm)
7272
}
73+
#[pymethod(magic)]
74+
fn str(&self, vm: &VirtualMachine) -> PyResult<PyStrRef> {
75+
match self.weak.upgrade() {
76+
Some(obj) => obj.str(vm),
77+
None => Err(vm.new_exception_msg(
78+
vm.ctx.exceptions.reference_error.clone(),
79+
"weakly-referenced object no longer exists".to_owned(),
80+
)),
81+
}
82+
}
7383
}
7484

7585
impl SetAttr for PyWeakProxy {

0 commit comments

Comments
 (0)