Fix tuple subclass preservation in type bases - #8420
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change stores ChangesTyped tuple bases and bootstrap hierarchy
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This change preserves tuple subclasses passed as type bases, and no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant ContextInit
participant TypeZooInit
participant InitTypeHierarchy
participant CoreTypes
ContextInit->>TypeZooInit: initialize types and empty_tuple
TypeZooInit->>InitTypeHierarchy: create BootstrapTypeHierarchy
InitTypeHierarchy->>CoreTypes: allocate and initialize core types and tuples
InitTypeHierarchy-->>TypeZooInit: return hierarchy and empty_tuple
TypeZooInit-->>ContextInit: return TypeZoo and empty_tuple
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/types.py dependencies:
dependent tests: (57 tests)
Legend:
|
69415b0 to
ff3c599
Compare
Store validated base classes in the original typed tuple, while retaining a bootstrap vector only until a Python tuple can be materialized. Assisted-by: gpt-5.6-sol
Initialize tuple and the canonical empty tuple alongside type and object so every type stores an actual typed bases tuple from construction. Remove the bootstrap bases representation and keep raw initialization Miri-safe. Assisted-by: Codex:gpt-5.6-sol
ff3c599 to
fd9cf58
Compare
Summary
type.__bases__always synthesized a fresh plaintuplefrom an internalVec<PyTypeRef>, so atuplesubclass passed as a base class lost its identity (CPython gh-132176).test_tuple_subclass_as_basesno longer needs@unittest.expectedFailure.PyType.basesis now a typedPyTuple<PyTypeRef>instead of aVec, so__bases__returns the stored tuple object directly — preserving a tuple subclass passed viabases=.tupleto exist as a real type before any other type (includingtype/object) is constructed, so bootstrap (init_type_hierarchy) now buildstupleand the canonical empty tuple alongsidetype/object.partially_init!macro bootstrap is replaced with explicit, Miri-safe helpers (init_ref_count,initial_ref,clone_raw_ref,init_inner).Written with Claude Code
Summary by CodeRabbit