Repository navigation
Share code construction and comparison controls - #9713
Draft
youknowdot wants to merge 5 commits into
Draft
youknowdot wants to merge 5 commits into
youknowdot wants to merge 5 commits into
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
youknowone
reviewed
Nov 6, 2026
| _owners: FuncArgs, | ||
| } | ||
|
|
||
| impl<T: CodeArgumentSpec> FromArgs for CodeArgs<T> { |
youknowdot
force-pushed
the
fix/code-controls-20261104
branch
from
November 6, 2026 14:00
4e49d67 to
4c33098
Compare
Assisted-by: OpenAI Codex:model version not exposed
Preserve argument owners, signed validation, audit and name-conversion order through shared construction. Match optional closure tuples and replacement controls without invoking tuple subclass iteration. Assisted-by: OpenAI Codex:model version not exposed
Remove redundant pyarg name overrides by naming the FromArgs fields codestring and constants. Preserve constructor storage mapping and Python signatures. Assisted-by: OpenAI: undisclosed
Preserve callback ownership, release ordering, and retained argument owners. Assisted-by: Codex:model-version-unavailable
Forward the derived binding metadata and let bind_for validate once before converting. Preserve original argument owners through conversion and audit callbacks. Assisted-by: OpenAI Codex:GPT-6
youknowdot
force-pushed
the
fix/code-controls-20261104
branch
from
November 7, 2026 01:53
4c33098 to
886c794
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Align code-object construction, replacement, comparison and hashing controls with Python 3.15 through shared validation and existing binding primitives in two Rust production files.
Validation
Compared against pinned CPython d220409a13b77de7a6c30abe16ea90db01528edc codeobject.c. The original four reference groups and nine expanded groups pass, covering callback order, early false/error exits, retained-field identity, local/cell partitions, original tuple hash caching and stable hashing after ordinary specialization. Constructed or modified code objects were not executed.
Independent source review passed, including bounds/traversal preservation, atomic reads, monitoring-lock scope and equality/hash consistency. Final threaded cargo check passed (1m04s), all-target Clippy passed (2m17s) with exactly the 12 unchanged baseline diagnostics, and normal commit hooks passed.
Limits and integration
The initial validation used external reference checks and source review. Current native validation is recorded in the shared-binding follow-up section; hosted CI remains necessary. No repository tests, markers, Lib files or workflows are changed.
The goal includes observable protocol callbacks and equality/hash consistency, not a promise of identical numerical hashes across distinct interpreter implementations. Signed constructor first-line representation differences remain outside this patch. #9688's filename repr work and #8939's constant-borrow ownership work remain separate and should be preserved on composition.
Integration with #9439 (head 95a4916) requires explicit reconciliation, not a clean automatic composition: retain that PR's removal of per-code monitoring data and its original_bytes-based deopt_code; omit this patch's extracted monitoring resolver and lock; hash through original_instructions_with with identity resolution. Its bounded base-instruction analysis helper has different stop semantics and should not replace serialization/hash traversal blindly. The retained-object comparison/hash controls are not duplicated by #9439.
Shared construction and replacement controls
The constructor's negative firstlineno still uses the existing unsigned internal line representation. In-place interning of externally referenced tuples, constant deduplication and exact interned filename/name identity, malformed bytecode parity, generic binder TypeError wording, and broader locals/line representation changes remain outside scope. Existing safe bytecode checks and location-array behavior are retained; no constructed or replaced code is executed in reference probes. #6894's old locals representation redesign is not duplicated, but would require source reconciliation if revived.
The current group changes 887 lines (+511/-376) in two production Rust files. Constructor-specific name diagnostics use native type names and the verified UTF-8-safe 500-byte bound. The added validation includes 103 focused and 103 independent pinned CPython cases, covering audit identity/veto/order, conversion and destruction order, structural errors, tuple subclass controls, mutable filename snapshots, flag retention and diagnostic bounds. Independent source review also confirmed that the original comparison/hash section is unchanged. These are reference checks and source review, not a claim that all oracle wording passes verbatim on RustPython.
Final follow-up validation: threaded host-env/VM/stdlib cargo check passed in 1m02s and all-targets Clippy in 2m20s, with exactly the 12 unchanged baseline diagnostics. The first compile exposed three borrowed-reference ownership conversions; those and two new lint findings were corrected, independently reviewed, and both final commands rerun. Normal commit hooks passed. Those earlier runs did not include full workspace, C-API or native runtime tests. Current results follow; separate WASM/non-threaded graphs remain unexecuted.
Shared-binding follow-up
Rebased independently onto main at fb57e68 and validated commit 886c794. The four existing commits are patch-identical after rebase. Later main changes through ea5fbcc affect ctypes and zlib, not the code-object or binding files used here.
PARAMSandBINDING_PARAMSfrom the typed arguments so shared Clinic validation runs once before conversion. Remove the duplicate arity/keyword preflight, temporary keyword-name vector, and private specification trait.Validation on this exact commit:
-D warnings.CARGO_PROFILE_TEST_DEBUG=0.-m test test_code: SUCCESS, 37 tests run and 15 skipped.The host PyO3 interpreter was the existing CPython 3.12.14, verified in the fresh build configuration. C-API checks used the repository's RustPython 3.15 configuration without an external interpreter. The pinned CPython 3.15 comparison is source-only; no CPython 3.15 executable was run for this follow-up. Hosted CI for the updated head remains pending.
AI assistance is disclosed in the commit trailers.