ctypes: expose frozen module tables - #1157
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
WalkthroughThe interpreter now exposes CPython-compatible frozen-module ABI tables. ChangesFrozen ABI and ctypes integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Ruff (0.16.1)lib-python/3/test/test_ctypes/test_arrays.py�[1;31mruff failed�[0m lib-python/3/test/test_ctypes/test_simplesubclasses.py�[1;31mruff failed�[0m lib-python/3/test/test_ctypes/test_struct_fields.py�[1;31mruff failed�[0m
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Codex parity reviewStatic analysis of this diff vs the local RPython/PyPy sources (commit 1b36253). Files in the reviewed diff1. Regressions to PyPy parity introduced by this patchNone. 2. Other mismatches introduced by this patchNone. 3. Pre-existing mismatches (already present before this patch)
4. Structural adaptations
|
What changed
_impfrozen-module census through the three ctypes_PyImport_Frozen*ABI tablesin_dll()frozen-symbol lookup through those stable process-global tablesPy_TPFLAGS_IMMUTABLETYPEassertions as CPython-only, preserving PyPy's publictype.__flags__contracttest.test_ctypesfromCRASHtoPASSin the CPython-suite baselineWhy
Pyre already owns a real frozen-module census in
_imp, but ctypes exposed an always-empty sentinel for every_PyImport_Frozen*symbol. The compatibility view now derives names, ordering, package flags, and payload storage from the existing owner rather than maintaining a second module census.The vendored CPython 3.14 suite also asserts CPython-specific immutable-type bits for ctypes internals. PyPy intentionally reports its own public
__flags__surface: static builtins do not gain that bit, and immutability remains enforced by the existing heap/static ownership path. Marking only those assertionscpython_onlykeeps the suite portable without changing runtime semantics.CI fix
The first version added
Py_TPFLAGS_IMMUTABLETYPEto every non-heap pyre type. That madesynth/pypy_type_surfacefail on Linux, macOS, and Windows because the fixture locks PyPy's public flag values. This revision restores the line-for-line PyPy flag calculation and limits the compatibility adjustment to the CPython-only tests.Validation
PYPYLOG=jit-summary:- pypy3 pyre/bench/synth/pypy_type_surface.pypython3 pyre/check.py --backend dynasm --synthetic-only --synthetic-pattern pypy_type_surface.py(1/1 passed)cargo check --features dynasmcargo test --features dynasmpython3 pyre/cpython_tests/run.py --backend dynasm --filter test_ctypes --timeout 300python3 pyre/cpython_tests/run.py --backend dynasm --no-jit --filter test_ctypes --full --timeout 300python3 pyre/check.py --backend dynasm --no-synthetic --no-cpython-suite(17/17 passed)Summary by CodeRabbit
Bug Fixes
ctypes.Tests
ctypestest suite now passes successfully.