Skip to content

Commit 27884e2

Browse files
committed
Add weakproxy bool
1 parent e5e98b7 commit 27884e2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Lib/test/test_weakref.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ def test_constructor_kwargs(self):
162162
c = C()
163163
self.assertRaises(TypeError, weakref.ref, c, callback=None)
164164

165-
# TODO: RUSTPYTHON
166-
@unittest.expectedFailure
167165
def test_proxy_ref(self):
168166
o = C()
169167
o.bar = 1
@@ -405,8 +403,6 @@ def __delitem__(self, accessor):
405403
del f[0]
406404
self.assertEqual(f.result, 0)
407405

408-
# TODO: RUSTPYTHON
409-
@unittest.expectedFailure
410406
def test_proxy_bool(self):
411407
# Test clearing of SF bug #1170766
412408
class List(list): pass

vm/src/builtins/weakproxy.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ impl PyWeakProxy {
7373
self.try_upgrade(vm)?.length(vm)
7474
}
7575

76+
#[pymethod(magic)]
77+
fn bool(&self, vm: &VirtualMachine) -> PyResult<bool> {
78+
self.try_upgrade(vm)?.is_true(vm)
79+
}
80+
7681
fn contains(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<bool> {
7782
let obj = self.try_upgrade(vm)?;
7883
PySequence::contains(&obj, &needle, vm)

0 commit comments

Comments
 (0)