⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align Template and Interpolation controls - #9709

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

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

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Align Template and Interpolation controls with Python 3.15 in two native Rust files (+86/-137).

  • Inherit object identity equality and hashing instead of comparing/hashing payloads structurally.
  • Bind Interpolation's four positional-or-keyword arguments with the existing ArgSpec parser before validating expression, conversion and format_spec in declaration order. Reuse conversion validation for internal and public construction.
  • Dispatch every interpolation repr field through the object protocol, including str-subclass format_spec overrides. Append and release each temporary repr result before invoking the next field; preserve WTF-8 output and exception order.
  • Reuse shared qualified-type formatting for Template construction/concatenation and conversion errors. Preserve Clinic's separate tp_name formatting for expression/format_spec errors.

The former format_spec call resolved the inherent PyStr repr and bypassed subclass overrides. This corrects protocol dispatch; it is not presented as a demonstrated panic fix.

Validation

Compared against CPython d220409a13b77de7a6c30abe16ea90db01528edc interpolationobject.c, templateobject.c and generated Clinic binding.

58 external CPython 3.15 assertions passed, including identity/hash callback non-invocation, named arguments, validation precedence, subtype preservation, repr callbacks/errors/surrogates, temporary-result cleanup and qualified diagnostics. Independent source/lifetime review passed. Corrected type metadata matches CPython's lack of an Interpolation type text signature; new keeps the shared generic wrapper.

Threaded cargo check passed (1m29s), all-target Clippy passed (3m27s) with exactly the 12 unchanged baseline diagnostics, and normal commit hooks passed. Native RustPython execution remains unperformed because its required safety guard is not verified. No repository tests, markers, Lib files or workflows are changed; hosted runtime CI remains necessary.

Limits and integration

  • Shared ArgSpec unexpected-keyword suggestions and lone-surrogate diagnostic formatting remain outside this change. The shared new wrapper's exact signature formatting is unchanged.
  • Raw constructor inputs remain owned through validation, but call-shape-dependent final argument teardown is controlled by shared FuncArgs/PyType calling machinery. Complete temporary-argument destruction parity is not claimed.
  • Template's distinction between omitted kwargs and explicitly empty **kwargs needs a broader call representation change and is deferred.
  • Constructor::Args changes from the removed public InterpolationArgs to FuncArgs; out-of-tree Rust consumers may need adjustment. In-tree consumers are checked.
  • Qualified names use the existing helper directly inside WTF-8 concatenation, remaining source-compatible with Preserve Unicode in shared qualified type names #9700's lossless return type change. No duplicate formatting helper is introduced.

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