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
PyPy 8.0.1 fixes the deallocation bug, but 8.0.x releases share an extension ABI. Retain the workaround throughout that minor series so extensions built with newer headers can still run on 8.0.0. Register PYPY_VERSION_NUM with the inline-header configuration checker.
Update the Linux Python 3.11 and macOS Python 3.12 jobs to PyPy 8.0.1. Keep Linux Python 3.12 on 8.0.0 to exercise the deallocation and memoryview workarounds without adding jobs.
Keep a pinned PyPy 7.3.23 / Python 3.11 job alongside the PyPy 8 matrix while PyPy 7 remains supported. Assisted-by: Codex
|
Commit 3d087e1 retains one explicitly pinned PyPy 7 CI job while this PR adds PyPy 8 coverage. Without that addition, the matrix update would remove our remaining PyPy 7 coverage, even though we have not decided to drop PyPy 7 support. The retained job runs PyPy 7.3.23 / Python 3.11 on Linux. This is particularly relevant to #6193, which restricts the explicit We have already tested the interaction between these PRs: the CI-only integration PR #6206 merges #6197 into #6193, and its full CI passed with 85 successful checks and two skips. Both conversion paths have therefore been tested together. I'll go ahead and merge this PR and #6193. Dropping PyPy 7 support can be discussed separately. If we decide to do so, we can remove the remaining PyPy 7 job and the workarounds needed only for PyPy 7 in a follow-up PR. |
🤖 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.