Skip to content

Commit 3664986

Browse files
Karatussyonmilk
andauthored
Fix weakref richcompare (#3913)
Co-Authored-By: Kim, Yeonwoo <oow214@gmail.com>
1 parent a77e9b6 commit 3664986

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Lib/test/test_weakref.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ def test_proxy_reuse(self):
228228
self.assertIs(proxy1, proxy2,
229229
"proxy object w/out callback should have been re-used")
230230

231-
# TODO: RUSTPYTHON
232-
@unittest.expectedFailure
233231
def test_basic_proxy(self):
234232
o = C()
235233
self.check_proxy(o, weakref.proxy(o))

vm/src/builtins/weakproxy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ crate::common::static_cell! {
5858
static WEAK_SUBCLASS: PyTypeRef;
5959
}
6060

61-
#[pyimpl(with(GetAttr, SetAttr, Constructor, AsSequence, AsMapping))]
61+
#[pyimpl(with(GetAttr, SetAttr, Constructor, Comparable, AsSequence, AsMapping))]
6262
impl PyWeakProxy {
6363
fn try_upgrade(&self, vm: &VirtualMachine) -> PyResult {
6464
self.weak.upgrade().ok_or_else(|| new_reference_error(vm))
@@ -88,6 +88,7 @@ impl PyWeakProxy {
8888
self.try_upgrade(vm)?.repr(vm)
8989
}
9090

91+
#[pymethod(magic)]
9192
fn contains(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<bool> {
9293
let obj = self.try_upgrade(vm)?;
9394
PySequence::contains(&obj, &needle, vm)

0 commit comments

Comments
 (0)