Repository navigation
Align namespace, super and dictionary controls - #9708
Conversation
Assisted-by: OpenAI Codex:model version not exposed
|
Caution Review failedThe pull request is closed.
Tip 🎯 Customize your risk assessments
✅ Automatic approvals, with your rules
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. |
Propagate key callback errors, retain live dictionary-backed class views, and revalidate shared read probes after equality and finalizer callbacks. Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Share fallible namespace reads with mapping proxies and retain original query behavior without holding the MRO lock across callbacks. Assisted-by: OpenAI Codex:model version not exposed
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Group namespace, mapping-proxy, super lookup and dictionary lookup/iterator controls for Python 3.15 in six Rust source files (+441/-456).
SimpleNamespace
Mapping proxies and shared dictionary lookup
Route containment through fallible mapping controls, propagating hash/equality failures rather than panicking. Native namespace fallback lookups also honor dictionary key callbacks.
Delegate union and str to the underlying mappings, preserve arbitrary callback results, accept the named mapping constructor argument, and correct inplace-union diagnostics.
Keep dictionary-backed class views and iterators attached to the actual namespace; copy remains a separate operation. Preserve Align mapping boundaries with Python 3.15 final #9128's defensive exact-dict copy for unknown comparison peers and Preserve raw mappingproxy rich-comparison results #9039's raw comparison results.
Revalidate shared read probes after equality and temporary-key finalizers. Check the current table and candidate before using its entry, restart invalid probes, and extract values under the validated read guard. Do not retain earlier rejected keys or introduce a second per-method probe algorithm.
Make cached dictionary hints identity-only, avoiding unrelated key equality and stale values. Reuse the same validated lookup extraction for refreshed hints, so values are cloned before releasing the read guard.
Dictionary iterators
Super namespace lookup
obj.__class__lookup, correct the missing zero-argument class-cell exception, preserve native type-name prefixes and 200-byte diagnostics, and reject keywords before positional binding through a small preflight around the existing argument binder.Validation
Limits
Native RustPython execution remains unperformed because the required safety guard is not verified. One existing Rust unit-test invocation is mechanically adjusted for the now-infallible hint API; its assertion and expected value are unchanged. No Python tests, test markers, or workflows were modified. Hosted runtime CI remains necessary.
Attributes-backed native namespaces still require materialized snapshots. This includes mutable AST namespace views, callbacks changing those namespaces, and union-exposed backing-dictionary identity. Only actual dictionary-backed class namespaces become live; no type-storage redesign is included. For super lookups with callback-bearing queries, a native AST namespace mutation can still leave the materialized snapshot stale and postpone destruction of replaced values. The native exact-string fast path has no Python key callbacks.
The read-probe correction uses allocation identity like CPython, not a new mutation-history counter. Same-key clear/reinsert callback counts can depend on allocator reuse; no universal count claim is made for that case. Hinted reads are included; concurrent races after separate mutation lookup/commit phases, including pop/remove_if, remain outside this patch. No broad operation-atomicity or native stress-test claim is made. Existing module-qualification differences in SimpleNamespace replacement rejection diagnostics are also unchanged.
Integration: #9681's separate reentrant LRU mutation helpers are unchanged and must remain on composition. Older #6215 instead raises on changed dictionary size; this patch follows CPython restart semantics rather than adopting that behavior. Broad ownership work in #8944/#8939 may require textual reconciliation. Those PRs already include an owned super MRO snapshot; preserve that change when composing. They do not supply the fallible raw namespace/query controls added here.
Dictionary iterator limitations: private relocation guards remain conservative for internal compaction. Cached item-result tuple ownership/identity and view-intersection error cleanup remain separately identified follow-ups; this patch does not mutate published tuples or claim those fixes. No concurrent stress/benchmark pass is claimed.
Ownership integration detail: #8939/#8944 create AST classes as interpreter-local heap types with real dictionaries. That should remove the specific AST snapshot gap when combined with this lookup helper, but this conclusion is source-only. The new owned dictionary accessor must resolve their interpreter-local namespace before returning it; shared native runtime namespaces should use a real interpreter-owned dictionary. Preserve bootstrap Attributes, stable native identities and registry initialization/GC ordering. Do not attach a runtime dictionary to a process-global native definition or keep a second value-owning Attributes mirror. This integration has not been implemented or compiled in this PR.