Repository navigation
Conversation
Fix two problems found with PyPy 3.12: - Deallocating a py::dynamic_attr() instance aborted, because PyPy 3.12's _PyObject_GetDictPtr() cannot be called from tp_dealloc. Read the dict slot from tp_dictoffset on PyPy instead. - memoryview::from_buffer() passed temporary shape/strides arrays, which PyPy keeps without copying. Use PyPy's inline _shape/_strides arrays. Assisted-by: ClaudeCode:claude-opus-5-5
A later PyPy GC at an arbitrary point can run the Python-calling destructor and abort. Assisted-by: ClaudeCode:claude-opus-5-5
henryiii
marked this pull request as ready for review
October 7, 2026 19:16
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Description
Test PyPy 8.0.0 in CI on both 3.11 and 3.12. PyPy 3.12 found two bugs:
py::dynamic_attr()instance aborted with "Invalid usage of a dying CPython object". PyPy 3.12's_PyObject_GetDictPtr()now publishes the dict into the C slot and cannot be called fromtp_dealloc(on 3.11 it always returned NULL). On PyPy, pybind11 now reads the slot fromtp_dictoffset.test_mi_dynamic_attributesnow runs the GC so that the crash is deterministic.memoryview::from_buffer()passes temporary shape/strides arrays. PyPy (8.0.0 and older) keeps these pointers without copying them unless they point to the inline_shape/_stridesarrays ofPy_buffer. On 3.12 this gave aMemoryError. On PyPy, pybind11 now copies the values into those arrays. Upstream PyPy fixed this on the py3.12 branch after 8.0.0.I ran the full test suite locally on macOS with PyPy 3.11 and 3.12 (8.0.0).
Suggested changelog entry:
py::dynamic_attr()instances and a dangling shape/strides pointer inmemoryview::from_buffer()on PyPy.