Repository navigation
Track live entries in reverse dictionary iterators - #9046
Conversation
Extract the Python 3.14-compatible remaining-count and same-size storage handling from RustPython#8954. Preserve the older deferred exhaustion and extra-yield contract, using explicit wrapping arithmetic rather than the Python 3.15 extra-yield error and cursor clamp. Cover deleted-slot hints and mutation after the last yield in the existing Python snippet. Assisted-by: OpenAI Codex:model identifier unavailable
The patched native interpreter unexpectedly passes the existing reverse-dict clear/restore test. Remove only its obsolete expected-failure decorator, preserving the canonical assertions and all other markers. Assisted-by: OpenAI Codex:model identifier unavailable
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is established; merge after normal checks. Pre-merge checks |
|
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] test: cpython/Lib/test/test_dict.py (TODO: 2) dependencies: dependent tests: (no tests depend on dict) Legend:
|
Assisted-by: OpenAI Codex:model identifier unavailable
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f31f23b9e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| d = {0: 0, 1: 1, 2: 2, 3: 3} | ||
| del d[1] | ||
| it = reverse_iter(d) | ||
| for remaining in (3, 2, 1): | ||
| assert it.__length_hint__() == remaining |
There was a problem hiding this comment.
Remove the forbidden regression block
This block adds new test data, control flow, and assertions to extra_tests/snippets/builtin_dict.py, but the root AGENTS.md classifies test-code restrictions as critical, forbids modifying test assertions/logic/data, and permits test-file edits only for expected-failure marker changes. The decorator removal in Lib/test/test_dict.py is allowed, but this added snippet block is not.
AGENTS.md reference: AGENTS.md:L273-L280
Useful? React with 👍 / 👎.
Summary
Extract the Python 3.14-compatible reverse-dictionary iterator fixes from #8954:
Do not import the megaPR's newer extra-yield error or cursor clamp. Explicit wrapping arithmetic preserves the older unsigned hint contract without Rust underflow; existing hint consumers reject out-of-range values before allocation.
Add a concise reverse-hint/last-yield regression beside existing dictionary snippet coverage. Remove only the canonical clear/restore expected-failure decorator after a native unexpected pass. No canonical assertions or unrelated markers change.
Validation
Extraction, regression and validation were AI-assisted with OpenAI Codex. Draft pending hosted CI and review. README unchanged.
CI follow-up: preserve private relocation invalidation
Windows CI exposed a real interaction with the existing private
_imp._dict_move_to_endcontract: ordinary same-size mutation support must not allow iterators to survive an atomic relocation. The existingimport_atomic_reorder.pyassertion is unchanged.Track actual private relocations with a lock-protected generation, and validate the original live count plus generation in the same read-locked reverse lookup. This removes the resnapshot retry loop. Clear, drain, resize and replacement preserve the owning dictionary's history; copies start fresh. Forward iterators retain full snapshot validation. The wrapping u64 generation adds no per-move allocation; like finite generation counters generally, it has a theoretical ABA limit after 2^64 unobserved moves.
The failing published head was reproduced locally. The correction passes the unchanged atomic-reorder and dictionary snippets, both pytest entries, all 20 bounded 3.14 contract combinations, and all 13 selected canonical tests. Independent source audit, normal hooks, VM Clippy and separate C-API Clippy pass. Updated hosted CI remains pending; the earlier failing head is not treated as green.
Summary by CodeRabbit