mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Add weakproxy bool
This commit is contained in:
1 parent
e5e98b79cb
commit
27884e2d5f
2 files changed
+5
-4
No files matched your search
Vendored
-4
@@ -162,8 +162,6 @@ class ReferencesTestCase(TestBase):
|
||||
c = C()
|
||||
self.assertRaises(TypeError, weakref.ref, c, callback=None)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_proxy_ref(self):
|
||||
o = C()
|
||||
o.bar = 1
|
||||
@@ -405,8 +403,6 @@ class ReferencesTestCase(TestBase):
|
||||
del f[0]
|
||||
self.assertEqual(f.result, 0)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_proxy_bool(self):
|
||||
# Test clearing of SF bug #1170766
|
||||
class List(list): pass
|
||||
|
||||
@@ -73,6 +73,11 @@ impl PyWeakProxy {
|
||||
self.try_upgrade(vm)?.length(vm)
|
||||
}
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn bool(&self, vm: &VirtualMachine) -> PyResult<bool> {
|
||||
self.try_upgrade(vm)?.is_true(vm)
|
||||
}
|
||||
|
||||
fn contains(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<bool> {
|
||||
let obj = self.try_upgrade(vm)?;
|
||||
PySequence::contains(&obj, &needle, vm)
|
||||
|
||||
Reference in new issue
Block a user