diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 2e8e679c8..224130110 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -380,7 +380,6 @@ class ReferencesTestCase(TestBase): # was not honored, and was broken in different ways for # PyWeakref_NewRef() and PyWeakref_NewProxy(). (Two tests.) - @unittest.expectedFailure # TODO: RUSTPYTHON def test_shared_ref_without_callback(self): self.check_shared_without_callback(weakref.ref) diff --git a/crates/vm/src/builtins/weakref.rs b/crates/vm/src/builtins/weakref.rs index 11e216847..9e88ffaa2 100644 --- a/crates/vm/src/builtins/weakref.rs +++ b/crates/vm/src/builtins/weakref.rs @@ -49,7 +49,7 @@ impl Constructor for PyWeak { let referent = positional .next() .ok_or_else(|| vm.new_type_error("__new__ expected at least 1 argument, got 0"))?; - let callback = positional.next(); + let callback = positional.next().filter(|callback| !vm.is_none(callback)); if let Some(_extra) = positional.next() { let got = positional.count() + 3; return Err(