Title: Embedded _weakref semantics are incomplete for PyO3 weakref compatibility
Using current RustPython tip (d201c48) through the PyO3 RustPython backend, the remaining weakref test failures narrow to _weakref semantics rather than generic backend bring-up.
Observed behavior:
PyWeakrefReference::upgrade() can work when backed by _weakref.ReferenceType
ReferenceType.__callback__ behavior appears wrong / missing
- proxy / anyref upgrade paths still fail when routed through
_weakref
- these no longer go through stdlib
weakref import recursion once the backend switches to _weakref
Representative PyO3 failures:
types::weakref::reference::tests::python_class::test_weakref_reference_behavior
- fails on
reference.getattr("__callback__") expecting None
types::weakref::anyref::tests::python_class::test_weakref_upgrade
- fails because the generic weakref path cannot recover the referent from proxy/reference uniformly
Likely gap:
- RustPython's built-in weakref / weakproxy public behavior does not yet fully match CPython / PyO3 expectations for:
ReferenceType.__callback__
- proxy/reference upgrade interoperability through the C-API-compatible surface
- possibly
PyWeak / PyWeakProxy exposure through _weakref
Relevant RustPython files:
crates/vm/src/builtins/weakref.rs
crates/vm/src/builtins/weakproxy.rs
crates/vm/src/stdlib/_weakref.rs
crates/vm/src/object/core.rs
If helpful, I can follow up with a smaller RustPython-only repro, but this is currently the main remaining blocker for the PyO3 weakref test cluster.
Title: Embedded
_weakrefsemantics are incomplete for PyO3 weakref compatibilityUsing current RustPython tip (
d201c48) through the PyO3 RustPython backend, the remaining weakref test failures narrow to_weakrefsemantics rather than generic backend bring-up.Observed behavior:
PyWeakrefReference::upgrade()can work when backed by_weakref.ReferenceTypeReferenceType.__callback__behavior appears wrong / missing_weakrefweakrefimport recursion once the backend switches to_weakrefRepresentative PyO3 failures:
types::weakref::reference::tests::python_class::test_weakref_reference_behaviorreference.getattr("__callback__")expectingNonetypes::weakref::anyref::tests::python_class::test_weakref_upgradeLikely gap:
ReferenceType.__callback__PyWeak/PyWeakProxyexposure through_weakrefRelevant RustPython files:
crates/vm/src/builtins/weakref.rscrates/vm/src/builtins/weakproxy.rscrates/vm/src/stdlib/_weakref.rscrates/vm/src/object/core.rsIf helpful, I can follow up with a smaller RustPython-only repro, but this is currently the main remaining blocker for the PyO3 weakref test cluster.