⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align function construction and metadata controls - #9717

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/function-controls-20261104
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/function-controls-20261104

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Align function construction and public metadata controls with Python 3.15 in one production Rust file (+209/-68).

  • Reuse the shared ArgSpec binder before validating supplied objects. Accept code/globals keywords, retain raw argument owners, and match closure/default/kwdefault validation order and constructor audit veto.
  • Emit public code/default/kwdefault read and mutation audits with the correct payloads and None-as-delete behavior. Read live fields after hooks and propagate vetoes before changes. Keep internal defaults accessors unaudited and release all locks before hooks or finalizers.
  • Match code/name/type-parameter setter diagnostics, using the live function name after audit. Preserve lone-surrogate names in function repr and closure-count errors without invoking string-subclass formatting callbacks.
  • Initialize doc only from a string first constant when the code declares a docstring. Preserve existing metadata identity, version invalidation and release-outside-lock behavior.

No handwritten per-function argument parser, tests, Lib, markers or workflow changes. Existing bound-method and annotation changes remain outside this patch.

Validation

Compared with pinned CPython function controls and its generated Clinic signature. Independent source review passed, including owner lifetimes, audit timing/payloads, lock boundaries and unaudited internal callers.

Reference probes passed 71 metadata cases, four doc initialization cases, 1,024 positional/keyword layouts compared with the shared binder model, and 27 additional metadata/Unicode/hook cases. Constructed or modified code/functions were only inspected, never executed. These are CPython/source checks, not a RustPython runtime pass.

Limits and integration

Old code ownership remains deferred by the existing swap_to_temporary_refs mechanism. CPython releases old code constants earlier, but changing that here would undermine the outstanding-borrow safety design; no immediate-destruction parity is claimed. Shared unexpected-keyword surrogate formatting also remains unchanged. Function deallocation/GC redesign, JIT behavior and annotation reentrancy are outside scope.

Fresh relevant PR patches were checked and do not duplicate this group. Composing #9715 has one textual conflict in function.rs imports: retain this patch's PyDict/PyTypeRef imports and remove PyList once its custom method directory is removed. Independent read-only apply checks confirmed all other hunks apply after that import-only resolution. Combined branches were not compiled or executed. Preserve #9700 annotation diagnostics; that region is unchanged here. #6894 changes freevar representation, and #8624 has adjacent JIT invalidation work that requires preserving its logic if integrated. No combined runtime claim is made.

Native RustPython execution, full workspace/C-API suites and separate cross-platform graphs remain unperformed. Hosted CI is required.

AI-assisted implementation and independent review using OpenAI Codex; model version is not exposed.

Final validation: threaded host-env/VM/stdlib cargo check passed in 1m26s and all-targets Clippy in 3m00s. All 12 existing baseline diagnostics match exactly. Normal repository commit hooks passed; no suppression or unrelated baseline changes.

Preserve constructor binding, validation, audit veto and argument owners. Audit public metadata without changing internal reads, retaining live-field semantics and Unicode names.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant