Skip to content

Align Template and Interpolation controls - #9709

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/template-controls-20261104
Nov 5, 2026
Merged

youknowone merged 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

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7e9a375 and f93b610.

Files selected for processing: 2

  • crates/vm/src/builtins/interpolation.rs
  • crates/vm/src/builtins/template.rs
  • 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

@youknowone
youknowone marked this pull request as ready for review November 5, 2026 03:07
@youknowone
youknowone enabled auto-merge (squash) November 5, 2026 03:07
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T03:07:17.866003Z
We couldn’t complete this review. Comment @codex review to try again.
f93b610 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@youknowone
youknowone merged commit 3fcaa16 into RustPython:main Nov 5, 2026
18 of 20 checks passed
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.

2 participants