(
_cls: &Py<PyType>,
Self::Args { referent, callback }: Self::Args,
vm: &VirtualMachine,
)
| 38 | type Args = WeakProxyNewArgs; |
| 39 | |
| 40 | fn py_new( |
| 41 | _cls: &Py<PyType>, |
| 42 | Self::Args { referent, callback }: Self::Args, |
| 43 | vm: &VirtualMachine, |
| 44 | ) -> PyResult<Self> { |
| 45 | // using an internal subclass as the class prevents us from getting the generic weakref, |
| 46 | // which would mess up the weakref count |
| 47 | let weak_cls = WEAK_SUBCLASS.get_or_init(|| { |
| 48 | vm.ctx.new_class( |
| 49 | None, |
| 50 | "__weakproxy", |
| 51 | vm.ctx.types.weakref_type.to_owned(), |
| 52 | super::PyWeak::make_slots(), |
| 53 | ) |
| 54 | }); |
| 55 | // TODO: PyWeakProxy should use the same payload as PyWeak |
| 56 | Ok(Self { |
| 57 | weak: referent.downgrade_with_typ(callback.into_option(), weak_cls.clone(), vm)?, |
| 58 | }) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | crate::common::static_cell! { |
nothing calls this directly
no test coverage detected