Skip to content

Align percent formatting with Python 3.15 final - #9125

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:split/percent-format-315-final
Oct 15, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:split/percent-format-315-final

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Align str, bytes and bytearray percent formatting with CPython 3.15 final: parse and convert fields in order, preserve mapping lookup/callback precedence, and include argument context in errors.
  • Match keyed conversion restrictions, star width/precision conversion, unsupported-character diagnostics, and qualified conversion type names.
  • Preserve main's invalid-character-length-before-index behavior from Check percent-c character lengths before index conversion #9052 and existing precision/integer conversion behavior from Fix percent-format precision and integer conversion #8876.
  • Use fallible output reservation for width padding and add six small callback-order cases to the existing string snippet.

Focused extraction from #8954 onto main 0f93210. Only two Rust files and an appended snippet function; no Lib edits, dependency changes, compiler/IR work, OS APIs or XML changes.

Validation

  • Fresh narrow release build with threading, stdlib, stdio, importlib and host_env passed on Linux x86-64.
  • Eleven exact canonical final-source cases passed, each in a fresh process with a 30-second timeout and 1 GiB address-space limit; zero skips or expected failures.
  • Existing Check percent-c character lengths before index conversion #9052 character-subclass regression and the new callback-order function passed separately under the same limits.
  • cargo clippy --locked -p rustpython-common -p rustpython-vm --all-targets -- -D warnings, normal repository hooks and git diff --check passed.
  • Preserved binary SHA256: 80a9afe1c3a2fb17db0183e18e6428d24c85b7dfd1c1cd6e4075a9cf9275745b.

Source review: the exact diff and runners passed independent review. Canonical method/helper ASTs match CPython d220409a13b77de7a6c30abe16ea90db01528edc; the runner uses minimal harness classes and requires 64-bit sizes before allowing methods with unreachable 32-bit allocation branches. Existing #9052 snippet logic is unchanged.

Limits

No full workspace/C-API suites, complete Python formatting/string/bytes suites, 32-bit/Windows/WASM runtime, concurrency or huge-allocation probes. Fallible width reservation is not a general huge-precision safety claim. No performance or human manual validation is claimed.

AI assistance: OpenAI Codex prepared the extraction, source review and validation tooling. The exact model version is not exposed by this runtime. Publication follows the maintainer’s authorized split workflow.

Parse and convert percent fields in order, preserve callback precedence, and align argument-context errors and keyed conversion restrictions. Keep invalid character-length checks ahead of index conversion and cover bounded callback ordering.

Assisted-by: OpenAI Codex:model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3e4cef7-e04d-4ea7-b7e2-d9d6e634724c
📥 Commits

Reviewing files that changed from the base of the PR and between 0f93210 and 4c3fff8.

📒 Files selected for processing: 3
  • crates/common/src/cformat.rs
  • crates/vm/src/cformat.rs
  • extra_tests/snippets/builtin_str.py
+-------------------------------------------+
| I am a verified code reviewer on Twitter. |
+-------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@youknowone
youknowone marked this pull request as ready for review October 15, 2026 01:28
@youknowone
youknowone merged commit 8b2f9d8 into RustPython:main Oct 15, 2026
21 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

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 ✅ Completed 2026-10-15T01:37:48.485186Z 4c3fff8 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c3fff85ff

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

)


def test_percent_callback_order_bounded():

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the newly added snippet test

This function adds new test logic and assertions to a test file, but the root AGENTS.md states that the only acceptable test-file edits are adding an expectedFailure marker or removing one together with its TODO; this change is neither permitted case and should be removed from the patch.

AGENTS.md reference: AGENTS.md:L273-L280

Useful? React with 👍 / 👎.

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