Skip to content

Opaque PyObject ABI support#5807

Draft
ngoldbaum wants to merge 20 commits intoPyO3:mainfrom
ngoldbaum:opaque-pyobject
Draft

Opaque PyObject ABI support#5807
ngoldbaum wants to merge 20 commits intoPyO3:mainfrom
ngoldbaum:opaque-pyobject

Conversation

@ngoldbaum
Copy link
Contributor

@ngoldbaum ngoldbaum commented Feb 13, 2026

Towards fixing #5786.

This is done on top of #5753 because that PR is needed to make this work.

With some help from @davidhewitt, this almost works but subclassing seems to be broken.

---- pycell::tests::test_pyref_as_super stdout ----
[src/pycell.rs:833:13] &pyref.inner = <builtins.SubSubClass object at 0x104ee6940>
[src/pycell.rs:834:13] &pyref.as_super().inner = <builtins.SubSubClass object at 0x104ee6940>

thread 'pycell::tests::test_pyref_as_super' (263860852) panicked at src/pycell.rs:835:13:
assertion `left == right` failed
  left: 20
 right: 10

I suspect using Layout to fill in LayoutAsBase is incorrect here:

type LayoutAsBase = <Self as #pyo3_path::impl_::pyclass::PyClassImpl>::Layout;

But I'm not sure how to update the macros and the macro wrappers to get that to work correctly.

@Icxolu do you happen to have any insight about what's going wrong?

TODO:

  • Hide PyModuldeDef in the FFI bindings.
  • Make tests fully pass

@ngoldbaum ngoldbaum added the CI-no-fail-fast If one job fails, allow the rest to keep testing label Feb 13, 2026
@ngoldbaum
Copy link
Contributor Author

Interesting: the careful tests fail in exactly the same way as the tests fail on the opaque pyobject build. Maybe a useful hint that there's some unsafety happening somewhere...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI-build-full CI-no-fail-fast If one job fails, allow the rest to keep testing free-threading proc-macro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant